blob: f71446f914971f4fdbe21de1a4a4fe7ff7633531 [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
John Zulauf620755c2018-04-16 11:00:43 -060088template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -070089ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
90 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -060091 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -070092 ExtEnabled state =
93 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -060094 return state;
95}
96
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070097bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -050098 const VkAllocationCallbacks *pAllocator,
99 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700100 bool skip = false;
101 // Note: From the spec--
102 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
103 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
104 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700105 ? pCreateInfo->pApplicationInfo->apiVersion
106 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700107 skip |= validate_api_version(local_api_version, api_version);
108 skip |= validate_instance_extensions(pCreateInfo);
109 return skip;
110}
111
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700112void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700113 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
114 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700115 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
116 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700117 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700118 this->instance_extensions = instance_data->instance_extensions;
119}
120
121void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700122 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700123 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700124 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700125 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
126 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700127
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700128 // Parmeter validation also uses extension data
129 stateless_validation->device_extensions = this->device_extensions;
130
131 VkPhysicalDeviceProperties device_properties = {};
132 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600133 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700134 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
135
136 if (device_extensions.vk_nv_shading_rate_image) {
137 // Get the needed shading rate image limits
138 auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
139 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600140 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700141 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
142 }
143
144 if (device_extensions.vk_nv_mesh_shader) {
145 // Get the needed mesh shader limits
146 auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>();
147 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600148 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700149 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
150 }
151
Jason Macnak5c954952019-07-09 15:46:12 -0700152 if (device_extensions.vk_nv_ray_tracing) {
153 // Get the needed ray tracing limits
154 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>();
155 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
156 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500157 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
158 }
159
160 if (device_extensions.vk_khr_ray_tracing) {
161 // Get the needed ray tracing limits
162 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesKHR>();
163 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
164 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
165 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700166 }
167
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700168 if (device_extensions.vk_ext_transform_feedback) {
169 // Get the needed transform feedback limits
170 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
171 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
172 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
173 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
174 }
175
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800176 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
177
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700178 // Save app-enabled features in this device's validation object
179 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200180 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
181 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
182 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
183 if (features2) {
184 tmp_features2_state.features = features2->features;
185 } else if (pCreateInfo->pEnabledFeatures) {
186 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700187 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200188 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700189 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200190 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700191 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200192 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700193}
194
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700195bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500196 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600197 bool skip = false;
198
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200199 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
200 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
201 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600202 }
203
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200204 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
205 skip |=
206 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
207 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
208 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
209 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600210 }
211
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200212 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700213 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
214 bool negative_viewport =
215 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200216 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700217 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
218 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
219 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200220 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600221 }
222
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600223 {
224 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
225 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
226 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700227 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
228 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
229 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600230 }
231 }
232
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600233 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
234 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600235 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
236 if (features2) {
237 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700238 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700239 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
240 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600241 }
242 }
243
Locke77fad1c2019-04-16 13:09:03 -0600244 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
245 if (features2) {
246 if (!instance_extensions.vk_khr_get_physical_device_properties_2) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700247 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
248 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, "
249 "VK_KHR_get_physical_device_properties2 must be enabled when it creates an instance.");
Locke77fad1c2019-04-16 13:09:03 -0600250 }
251 }
252
Jeff Bolz165818a2020-05-08 11:19:03 -0500253 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
254 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
255 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
256 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
257 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
258 }
259
Locke77fad1c2019-04-16 13:09:03 -0600260 auto vertex_attribute_divisor_features =
261 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
262 if (vertex_attribute_divisor_features) {
263 bool extension_found = false;
264 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
265 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
266 VK_MAX_EXTENSION_NAME_SIZE)) {
267 extension_found = true;
268 break;
269 }
270 }
271 if (!extension_found) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700272 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
273 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
274 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600275 }
276 }
277
Tony-LunarG28017bc2020-01-23 14:40:25 -0700278 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
279 if (vulkan_11_features) {
280 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
281 while (current) {
282 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
283 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
284 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
285 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
286 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
287 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700288 skip |= LogError(
289 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700290 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
291 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
292 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
293 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
294 break;
295 }
296 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
297 }
298 }
299
300 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
301 if (vulkan_12_features) {
302 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
303 while (current) {
304 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
305 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
306 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
307 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
308 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
309 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
310 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
311 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
312 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
313 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
314 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
315 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
316 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700317 skip |= LogError(
318 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700319 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
320 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
321 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
322 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
323 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
324 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
325 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
326 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
327 break;
328 }
329 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
330 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700331 // Check features are enabled if matching extension is passed in as well
332 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
333 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
334 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
335 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
336 skip |= LogError(
337 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
338 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
339 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
340 }
341 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
342 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
343 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
344 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
345 "is not VK_TRUE.",
346 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
347 }
348 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
349 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
350 skip |= LogError(
351 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
352 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
353 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
354 }
355 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
356 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
357 skip |= LogError(
358 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
359 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
360 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
361 }
362 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
363 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
364 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
365 skip |=
366 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
367 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
368 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
369 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
370 }
371 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700372 }
373
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600374 // Validate pCreateInfo->pQueueCreateInfos
375 if (pCreateInfo->pQueueCreateInfos) {
376 std::unordered_set<uint32_t> set;
377
378 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700379 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
380 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600381 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700382 skip |=
383 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
384 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
385 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
386 "index value.",
387 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600388 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700389 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
390 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
391 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
392 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600393 } else {
394 set.insert(requested_queue_family);
395 }
396
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700397 if (queue_create_info.pQueuePriorities != nullptr) {
398 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
399 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600400 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700401 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
402 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
403 "] (=%f) is not between 0 and 1 (inclusive).",
404 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600405 }
406 }
407 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700408
409 // Need to know if protectedMemory feature is passed in preCall to creating the device
410 VkBool32 protectedMemory = VK_FALSE;
411 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
412 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
413 if (protected_features) {
414 protectedMemory = protected_features->protectedMemory;
415 } else if (vulkan_11_features) {
416 protectedMemory = vulkan_11_features->protectedMemory;
417 }
418 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) {
419 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
420 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
421 "protectedMemory feature being set as well.");
422 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600423 }
424 }
425
426 return skip;
427}
428
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500429bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700430 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700431 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
432 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
433 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600434 }
435
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700436 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600437}
438
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700439bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500440 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100441 bool skip = false;
442
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600443 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700444 skip |=
445 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600446
447 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
448 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
449 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
450 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700451 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
452 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
453 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600454 }
455
456 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
457 // queueFamilyIndexCount uint32_t values
458 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700459 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
460 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
461 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
462 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600463 }
464 }
465
466 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
467 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
468 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
469 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700470 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
471 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
472 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600473 }
474 }
475
476 return skip;
477}
478
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700479bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500480 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600481 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600482
483 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600484 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
485 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
486 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
487 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700488 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
489 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
490 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600491 }
492
493 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
494 // queueFamilyIndexCount uint32_t values
495 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700496 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
497 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
498 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
499 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600500 }
501 }
502
Dave Houlton413a6782018-05-22 13:01:54 -0600503 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700504 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600505 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700506 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600507 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700508 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600509
Dave Houlton413a6782018-05-22 13:01:54 -0600510 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700511 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600512 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700513 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600514
Dave Houlton130c0212018-01-29 13:39:56 -0700515 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700516 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
517 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700518 skip |= LogError(
519 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600520 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
521 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700522 }
523
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600524 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100525 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
526 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700527 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
528 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
529 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600530 }
531
532 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100533 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
534 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700535 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
536 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
537 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
538 ") are not equal.",
539 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100540 }
541
542 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700543 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
544 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
545 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
546 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100547 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600548 }
549
550 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700551 skip |= LogError(
552 device, "VUID-VkImageCreateInfo-imageType-00957",
553 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600554 }
555 }
556
Dave Houlton130c0212018-01-29 13:39:56 -0700557 // 3D image may have only 1 layer
558 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700559 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
560 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700561 }
562
563 // If multi-sample, validate type, usage, tiling and mip levels.
564 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
565 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600566 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700567 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
568 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700569 }
570
571 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
572 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
573 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
574 // At least one of the legal attachment bits must be set
575 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700576 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
577 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700578 }
579 // No flags other than the legal attachment bits may be set
580 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
581 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700582 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
583 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700584 }
585 }
586
Jeff Bolzef40fec2018-09-01 22:04:34 -0500587 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600588 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500589 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600590 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
591 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500592 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600593 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700594 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
595 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
596 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600597 }
598
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600599 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700600 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
601 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
602 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600603 }
604
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700605 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700606 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
607 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
608 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100609 }
610
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600611 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
612 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
613 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
614 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700615 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
616 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
617 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600618 }
619
620 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
621 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
622 // Linear tiling is unsupported
623 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700624 skip |= LogError(device, kVUID_PVError_InvalidUsage,
625 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
626 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600627 }
628
629 // Sparse 1D image isn't valid
630 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700631 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
632 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600633 }
634
635 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700636 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700637 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
638 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
639 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600640 }
641
642 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700643 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700644 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
645 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
646 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600647 }
648
649 // Multi-sample 2D image when device doesn't support it
650 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700651 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600652 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700653 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
654 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
655 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700656 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600657 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700658 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
659 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
660 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700661 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600662 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700663 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
664 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
665 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700666 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600667 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700668 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
669 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
670 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600671 }
672 }
673 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500674
Jeff Bolz9af91c52018-09-01 21:53:57 -0500675 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
676 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700677 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
678 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
679 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500680 }
681 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700682 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
683 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
684 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500685 }
686 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700687 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
688 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
689 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500690 }
691 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500692
693 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600694 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700695 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
696 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
697 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500698 }
699
Dave Houlton142c4cb2018-10-17 15:04:41 -0600700 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700701 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
702 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
703 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
704 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500705 }
706
Dave Houlton142c4cb2018-10-17 15:04:41 -0600707 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700708 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
709 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
710 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
711 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500712 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600713 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700714 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
715 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
716 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
717 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500718 }
719 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500720
sfricke-samsung8f658d42020-05-03 20:12:24 -0700721 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
722 (FormatHasDepth(pCreateInfo->format) == false)) {
723 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
724 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
725 "format must be a depth or depth/stencil format.");
726 }
727
Andrew Fobel3abeb992020-01-20 16:33:22 -0500728 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
729 if (image_stencil_struct != nullptr) {
730 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
731 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
732 // No flags other than the legal attachment bits may be set
733 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
734 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700735 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
736 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
737 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
738 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500739 }
740 }
741
742 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
743 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
744 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
745 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700746 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
747 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
748 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
749 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500750 }
751
752 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
753 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700754 LogError(device, "VUID-VkImageCreateInfo-format-02537",
755 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
756 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
757 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500758 }
759 }
760
761 if (!physical_device_features.shaderStorageImageMultisample &&
762 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
763 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
764 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700765 LogError(device, "VUID-VkImageCreateInfo-format-02538",
766 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
767 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
768 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500769 }
770
771 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
772 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700773 skip |= LogError(
774 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500775 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
776 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
777 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
778 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
779 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700780 skip |= LogError(
781 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500782 "vkCreateImage(): Depth-stencil image in which usage does not include "
783 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
784 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
785 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
786 }
787
788 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
789 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700790 skip |= LogError(
791 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500792 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
793 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
794 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
795 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
796 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700797 skip |= LogError(
798 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500799 "vkCreateImage(): Depth-stencil image in which usage does not include "
800 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
801 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
802 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
803 }
804 }
805 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700806
807 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
808 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
809 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
810 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
811 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
812 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700813
814 if (device_extensions.vk_ext_image_drm_format_modifier) {
815 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
816 const auto drm_format_mod_explict =
817 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
818 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
819 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
820 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
821 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
822 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
823 "either VkImageDrmFormatModifierListCreateInfoEXT or "
824 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
825 }
826 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
827 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
828 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
829 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
830 "in the pNext chain");
831 }
832 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600833 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500834
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600835 return skip;
836}
837
Jeff Bolz99e3f632020-03-24 22:59:22 -0500838bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
839 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
840 bool skip = false;
841
842 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700843 // Validate feature set if using CUBE_ARRAY
844 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
845 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
846 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
847 "enabling the imageCubeArray feature.");
848 }
849
Jeff Bolz99e3f632020-03-24 22:59:22 -0500850 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
851 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
852 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -0700853 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -0500854 pCreateInfo->subresourceRange.layerCount);
855 }
856 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700857 skip |= LogError(
858 device, "VUID-VkImageViewCreateInfo-viewType-02961",
859 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
860 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -0500861 }
862 }
863 }
864 return skip;
865}
866
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600867bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700868 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100869 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100870
871 // Note: for numerical correctness
872 // - float comparisons should expect NaN (comparison always false).
873 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
874
875 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -0700876 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100877 if (v1_f <= 0.0f) return true;
878
879 float intpart;
880 const float fract = modff(v1_f, &intpart);
881
882 assert(std::numeric_limits<float>::radix == 2);
883 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
884 if (intpart >= u32_max_plus1) return false;
885
886 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
887 if (v1_u32 < v2_u32)
888 return true;
889 else if (v1_u32 == v2_u32 && fract == 0.0f)
890 return true;
891 else
892 return false;
893 };
894
895 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
896 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
897 return (v1_f <= v2_f);
898 };
899
900 // width
901 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700902 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100903
904 if (!(viewport.width > 0.0f)) {
905 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700906 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
907 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100908 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
909 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700910 skip |= LogError(object, "VUID-VkViewport-width-01771",
911 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
912 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100913 } 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 -0700914 skip |= LogWarning(object, kVUID_PVError_NONE,
915 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
916 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
917 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100918 }
919
920 // height
921 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -0700922 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700923 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100924
925 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
926 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700927 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
928 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100929 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
930 height_healthy = false;
931
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700932 skip |= LogError(object, "VUID-VkViewport-height-01773",
933 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
934 ").",
935 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100936 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
937 height_healthy = false;
938
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700939 skip |= LogWarning(
940 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +0100941 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600942 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600943 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100944 }
945
946 // x
947 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700948 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100949 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700950 skip |= LogError(object, "VUID-VkViewport-x-01774",
951 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
952 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100953 }
954
955 // x + width
956 if (x_healthy && width_healthy) {
957 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700958 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700959 skip |= LogError(
960 object, "VUID-VkViewport-x-01232",
961 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
962 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
963 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100964 }
965 }
966
967 // y
968 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700969 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100970 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700971 skip |= LogError(object, "VUID-VkViewport-y-01775",
972 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
973 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700974 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100975 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700976 skip |= LogError(object, "VUID-VkViewport-y-01776",
977 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
978 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100979 }
980
981 // y + height
982 if (y_healthy && height_healthy) {
983 const float boundary = viewport.y + viewport.height;
984
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700985 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700986 skip |= LogError(object, "VUID-VkViewport-y-01233",
987 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
988 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
989 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700990 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600991 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700992 LogError(object, "VUID-VkViewport-y-01777",
993 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
994 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
995 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100996 }
997 }
998
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700999 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001000 // minDepth
1001 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001002 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001003
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001004 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1005 "[0.0, 1.0] range.",
1006 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001007 }
1008
1009 // maxDepth
1010 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001011 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001012
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001013 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1014 "[0.0, 1.0] range.",
1015 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001016 }
1017 }
1018
1019 return skip;
1020}
1021
Dave Houlton142c4cb2018-10-17 15:04:41 -06001022struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001023 VkShadingRatePaletteEntryNV shadingRate;
1024 uint32_t width;
1025 uint32_t height;
1026};
1027
1028// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -06001029static SampleOrderInfo sampleOrderInfos[] = {
1030 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1031 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1032 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1033 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1034 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1035 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001036};
1037
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001038bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001039 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001040
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001041 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001042 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001043 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001044 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001045 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001046 break;
1047 }
1048 }
1049
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001050 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001051 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1052 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1053 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001054 return skip;
1055 }
1056
Dave Houlton142c4cb2018-10-17 15:04:41 -06001057 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001058 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001059 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1060 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1061 ") must "
1062 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1063 "is set in framebufferNoAttachmentsSampleCounts.",
1064 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001065 }
1066
Jeff Bolz9af91c52018-09-01 21:53:57 -05001067 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001068 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1069 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1070 ") must "
1071 "be equal to the product of sampleCount (=%" PRIu32
1072 "), the fragment width for shadingRate "
1073 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1074 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001075 }
1076
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001077 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001078 skip |= LogError(
1079 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001080 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1081 ") must "
1082 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001083 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001084 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001085
1086 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001087 // the first width*height*sampleCount bits to all be set. Note: There is no
1088 // guarantee that 64 bits is enough, but practically it's unlikely for an
1089 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001090 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001091 uint64_t sampleLocationsMask = 0;
1092 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1093 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1094 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001095 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1096 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001097 }
1098 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001099 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1100 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001101 }
1102 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001103 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1104 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001105 }
1106 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1107 sampleLocationsMask |= 1ULL << idx;
1108 }
1109
1110 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1111 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001112 skip |= LogError(
1113 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001114 "The array pSampleLocations must contain exactly one entry for "
1115 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001116 }
1117
1118 return skip;
1119}
1120
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001121bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1122 uint32_t createInfoCount,
1123 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1124 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001125 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001126 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001127
1128 if (pCreateInfos != nullptr) {
1129 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001130 bool has_dynamic_viewport = false;
1131 bool has_dynamic_scissor = false;
1132 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001133 bool has_dynamic_depth_bias = false;
1134 bool has_dynamic_blend_constant = false;
1135 bool has_dynamic_depth_bounds = false;
1136 bool has_dynamic_stencil_compare = false;
1137 bool has_dynamic_stencil_write = false;
1138 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001139 bool has_dynamic_viewport_w_scaling_nv = false;
1140 bool has_dynamic_discard_rectangle_ext = false;
1141 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001142 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001143 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001144 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001145 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001146 if (pCreateInfos[i].pDynamicState != nullptr) {
1147 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1148 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1149 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001150 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1151 if (has_dynamic_viewport == true) {
1152 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1153 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1154 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1155 i);
1156 }
1157 has_dynamic_viewport = true;
1158 }
1159 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1160 if (has_dynamic_scissor == true) {
1161 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1162 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1163 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1164 i);
1165 }
1166 has_dynamic_scissor = true;
1167 }
1168 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1169 if (has_dynamic_line_width == true) {
1170 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1171 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1172 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1173 i);
1174 }
1175 has_dynamic_line_width = true;
1176 }
1177 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1178 if (has_dynamic_depth_bias == true) {
1179 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1180 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1181 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1182 i);
1183 }
1184 has_dynamic_depth_bias = true;
1185 }
1186 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1187 if (has_dynamic_blend_constant == true) {
1188 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1189 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1190 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1191 i);
1192 }
1193 has_dynamic_blend_constant = true;
1194 }
1195 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1196 if (has_dynamic_depth_bounds == true) {
1197 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1198 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1199 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1200 i);
1201 }
1202 has_dynamic_depth_bounds = true;
1203 }
1204 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1205 if (has_dynamic_stencil_compare == true) {
1206 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1207 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1208 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1209 i);
1210 }
1211 has_dynamic_stencil_compare = true;
1212 }
1213 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1214 if (has_dynamic_stencil_write == true) {
1215 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1216 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1217 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1218 i);
1219 }
1220 has_dynamic_stencil_write = true;
1221 }
1222 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1223 if (has_dynamic_stencil_reference == true) {
1224 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1225 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1226 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1227 i);
1228 }
1229 has_dynamic_stencil_reference = true;
1230 }
1231 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1232 if (has_dynamic_viewport_w_scaling_nv == true) {
1233 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1234 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1235 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1236 i);
1237 }
1238 has_dynamic_viewport_w_scaling_nv = true;
1239 }
1240 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1241 if (has_dynamic_discard_rectangle_ext == true) {
1242 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1243 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1244 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1245 i);
1246 }
1247 has_dynamic_discard_rectangle_ext = true;
1248 }
1249 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1250 if (has_dynamic_sample_locations_ext == true) {
1251 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1252 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1253 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1254 i);
1255 }
1256 has_dynamic_sample_locations_ext = true;
1257 }
1258 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1259 if (has_dynamic_exclusive_scissor_nv == true) {
1260 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1261 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1262 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1263 i);
1264 }
1265 has_dynamic_exclusive_scissor_nv = true;
1266 }
1267 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1268 if (has_dynamic_shading_rate_palette_nv == true) {
1269 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1270 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1271 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1272 i);
1273 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001274 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001275 }
1276 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1277 if (has_dynamic_viewport_course_sample_order_nv == true) {
1278 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1279 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1280 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1281 i);
1282 }
1283 has_dynamic_viewport_course_sample_order_nv = true;
1284 }
1285 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1286 if (has_dynamic_line_stipple == true) {
1287 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1288 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1289 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1290 i);
1291 }
1292 has_dynamic_line_stipple = true;
1293 }
Petr Kraus299ba622017-11-24 03:09:03 +01001294 }
1295 }
1296
Peter Chen85366392019-05-14 15:20:11 -04001297 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1298 if ((feedback_struct != nullptr) &&
1299 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001300 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1301 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1302 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1303 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1304 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001305 }
1306
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001307 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001308
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001309 // Collect active stages and other information
1310 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001311 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001312 bool has_eval = false;
1313 bool has_control = false;
1314 if (pCreateInfos[i].pStages != nullptr) {
1315 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1316 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1317
1318 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1319 has_control = true;
1320 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1321 has_eval = true;
1322 }
1323
1324 skip |= validate_string(
1325 "vkCreateGraphicsPipelines",
1326 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1327 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1328 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001329 }
1330
1331 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1332 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1333 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1334 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1335 pCreateInfos[i].pTessellationState,
1336 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1337 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1338
1339 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1340 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1341
1342 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1343 "VkPipelineTessellationDomainOriginStateCreateInfo",
1344 pCreateInfos[i].pTessellationState->pNext,
1345 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1346 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001347 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1348 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001349
1350 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1351 pCreateInfos[i].pTessellationState->flags,
1352 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1353 }
1354
1355 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1356 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1357 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1358 pCreateInfos[i].pInputAssemblyState,
1359 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1360 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1361
1362 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1363 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001364 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001365
1366 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1367 pCreateInfos[i].pInputAssemblyState->flags,
1368 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1369
1370 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1371 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1372 pCreateInfos[i].pInputAssemblyState->topology,
1373 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1374
1375 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1376 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1377 }
1378
1379 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001380 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001381
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001382 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001383 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1384 "vkCreateGraphicsPipelines: pararameter "
1385 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1386 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001387 }
1388
1389 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1390 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1391 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1392 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1393 pCreateInfos[i].pVertexInputState->pNext, 1,
1394 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001395 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1396 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001397 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1398 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001399 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001400 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1401 skip |=
1402 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1403 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1404 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1405 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1406 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1407
1408 skip |= validate_array(
1409 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1410 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1411 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1412 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1413
1414 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1415 for (uint32_t vertexBindingDescriptionIndex = 0;
1416 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1417 ++vertexBindingDescriptionIndex) {
1418 skip |= validate_ranged_enum(
1419 "vkCreateGraphicsPipelines",
1420 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1421 AllVkVertexInputRateEnums,
1422 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1423 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1424 }
1425 }
1426
1427 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1428 for (uint32_t vertexAttributeDescriptionIndex = 0;
1429 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1430 ++vertexAttributeDescriptionIndex) {
1431 skip |= validate_ranged_enum(
1432 "vkCreateGraphicsPipelines",
1433 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1434 AllVkFormatEnums,
1435 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1436 "VUID-VkVertexInputAttributeDescription-format-parameter");
1437 }
1438 }
1439
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001440 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001441 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1442 "vkCreateGraphicsPipelines: pararameter "
1443 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1444 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1445 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001446 }
1447
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001448 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001449 skip |=
1450 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1451 "vkCreateGraphicsPipelines: pararameter "
1452 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1453 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1454 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001455 }
1456
1457 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001458 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1459 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001460 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1461 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001462 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1463 "vkCreateGraphicsPipelines: parameter "
1464 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1465 "(%" PRIu32 ") is not distinct.",
1466 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001467 }
1468 vertex_bindings.insert(vertex_bind_desc.binding);
1469
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001470 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001471 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1472 "vkCreateGraphicsPipelines: parameter "
1473 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1474 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1475 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001476 }
1477
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001478 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001479 skip |=
1480 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1481 "vkCreateGraphicsPipelines: parameter "
1482 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1483 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1484 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001485 }
1486 }
1487
Peter Kohautc7d9d392018-07-15 00:34:07 +02001488 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001489 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1490 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001491 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1492 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001493 skip |= LogError(
1494 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001495 "vkCreateGraphicsPipelines: parameter "
1496 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1497 i, d, vertex_attrib_desc.location);
1498 }
1499 attribute_locations.insert(vertex_attrib_desc.location);
1500
1501 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1502 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001503 skip |= LogError(
1504 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001505 "vkCreateGraphicsPipelines: parameter "
1506 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1507 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1508 i, d, vertex_attrib_desc.binding, i);
1509 }
1510
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001511 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001512 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1513 "vkCreateGraphicsPipelines: parameter "
1514 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1515 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1516 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001517 }
1518
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001519 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001520 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1521 "vkCreateGraphicsPipelines: parameter "
1522 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1523 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1524 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001525 }
1526
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001527 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001528 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1529 "vkCreateGraphicsPipelines: parameter "
1530 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1531 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1532 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001533 }
1534 }
1535 }
1536
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001537 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1538 if (has_control && has_eval) {
1539 if (pCreateInfos[i].pTessellationState == nullptr) {
1540 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1541 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1542 "shader stage and a tessellation evaluation shader stage, "
1543 "pCreateInfos[%d].pTessellationState must not be NULL.",
1544 i, i);
1545 } else {
1546 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1547 skip |= validate_struct_pnext(
1548 "vkCreateGraphicsPipelines",
1549 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1550 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1551 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1552 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001553
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001554 skip |= validate_reserved_flags(
1555 "vkCreateGraphicsPipelines",
1556 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1557 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001558
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001559 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1560 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1561 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1562 "vkCreateGraphicsPipelines: invalid parameter "
1563 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1564 "should be >0 and <=%u.",
1565 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1566 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001567 }
1568 }
1569 }
1570
1571 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1572 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1573 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1574 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001575 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1576 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1577 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1578 "].pViewportState (=NULL) is not a valid pointer.",
1579 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001580 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001581 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1582
1583 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001584 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1585 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1586 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1587 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001588 }
1589
Petr Krausa6103552017-11-16 21:21:58 +01001590 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1591 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001592 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1593 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001594 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1595 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001596 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001597 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001598 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001599 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001600 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001601 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1602 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001603 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001604 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1605 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001606
1607 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001608 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001609 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001610 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001611
Dave Houlton142c4cb2018-10-17 15:04:41 -06001612 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1613 pCreateInfos[i].pViewportState->pNext);
1614 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1615 pCreateInfos[i].pViewportState->pNext);
1616 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1617 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001618 const auto vp_swizzle_struct =
1619 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001620 const auto vp_w_scaling_struct =
1621 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001622
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001623 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001624 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001625 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1626 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1627 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1628 ") is not 1.",
1629 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001630 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001631
Petr Krausa6103552017-11-16 21:21:58 +01001632 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001633 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1634 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1635 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1636 ") is not 1.",
1637 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001638 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001639
Dave Houlton142c4cb2018-10-17 15:04:41 -06001640 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1641 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001642 skip |= LogError(
1643 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1644 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1645 "disabled, but pCreateInfos[%" PRIu32
1646 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1647 ") is not 1.",
1648 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001649 }
1650
Jeff Bolz9af91c52018-09-01 21:53:57 -05001651 if (shading_rate_image_struct &&
1652 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001653 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
1654 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1655 "disabled, but pCreateInfos[%" PRIu32
1656 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
1657 ") is neither 0 nor 1.",
1658 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001659 }
1660
Petr Krausa6103552017-11-16 21:21:58 +01001661 } else { // multiViewport enabled
1662 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001663 skip |= LogError(
1664 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001665 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001666 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001667 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
1668 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1669 "].pViewportState->viewportCount (=%" PRIu32
1670 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1671 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001672 }
Petr Krausa6103552017-11-16 21:21:58 +01001673
1674 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001675 skip |= LogError(
1676 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001677 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001678 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001679 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
1680 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1681 "].pViewportState->scissorCount (=%" PRIu32
1682 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1683 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001684 }
1685 }
1686
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001687 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001688 skip |=
1689 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1690 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1691 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1692 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001693 }
1694
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001695 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001696 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1697 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1698 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1699 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1700 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001701 }
1702
Petr Krausa6103552017-11-16 21:21:58 +01001703 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001704 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
1705 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1706 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1707 "].pViewportState->viewportCount (=%" PRIu32 ").",
1708 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001709 }
1710
Dave Houlton142c4cb2018-10-17 15:04:41 -06001711 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001712 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001713 skip |=
1714 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1715 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1716 ") must be zero or identical to pCreateInfos[%" PRIu32
1717 "].pViewportState->viewportCount (=%" PRIu32 ").",
1718 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001719 }
1720
Dave Houlton142c4cb2018-10-17 15:04:41 -06001721 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001722 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001723 skip |= LogError(
1724 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001725 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1726 "] "
1727 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1728 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1729 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001730 }
1731
Petr Krausa6103552017-11-16 21:21:58 +01001732 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001733 skip |= LogError(
1734 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001735 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1736 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001737 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1738 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001739 }
1740
1741 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001742 skip |= LogError(
1743 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001744 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1745 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001746 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1747 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001748 }
1749
Jeff Bolz3e71f782018-08-29 23:15:45 -05001750 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001751 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1752 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1753 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001754 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-pDynamicStates-02030",
1755 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1756 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1757 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1758 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001759 }
1760
Jeff Bolz9af91c52018-09-01 21:53:57 -05001761 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001762 shading_rate_image_struct->viewportCount > 0 &&
1763 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001764 skip |= LogError(
1765 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-pDynamicStates-02057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001766 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001767 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1768 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001769 i, i);
1770 }
1771
Chris Mayer328d8212018-12-11 14:16:18 +01001772 if (vp_swizzle_struct) {
1773 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001774 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
1775 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
1776 " does "
1777 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
1778 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01001779 }
1780 }
1781
Petr Krausb3fcdb42018-01-09 22:09:09 +01001782 // validate the VkViewports
1783 if (!has_dynamic_viewport && viewport_state.pViewports) {
1784 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
1785 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001786 const char *fn_name = "vkCreateGraphicsPipelines";
1787 skip |= manual_PreCallValidateViewport(viewport, fn_name,
1788 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
1789 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001790 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01001791 }
1792 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001793
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001794 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001795 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1796 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1797 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
1798 "VK_NV_clip_space_w_scaling extension is not enabled.",
1799 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001800 }
1801
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001802 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001803 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1804 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1805 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
1806 "VK_EXT_discard_rectangles extension is not enabled.",
1807 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001808 }
1809
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001810 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001811 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1812 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1813 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
1814 "VK_EXT_sample_locations extension is not enabled.",
1815 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001816 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001817
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001818 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001819 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1820 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1821 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
1822 "VK_NV_scissor_exclusive extension is not enabled.",
1823 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001824 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001825
1826 if (coarse_sample_order_struct &&
1827 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
1828 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001829 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
1830 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1831 "] "
1832 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
1833 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
1834 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001835 }
1836
1837 if (coarse_sample_order_struct) {
1838 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001839 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001840 }
1841 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001842
1843 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
1844 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001845 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
1846 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1847 "] "
1848 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
1849 ") "
1850 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
1851 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001852 }
1853 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001854 skip |= LogError(
1855 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001856 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1857 "] "
1858 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
1859 i);
1860 }
1861 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001862 }
1863
1864 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001865 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
1866 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
1867 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
1868 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001869 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07001870 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
1871 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
1872 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07001873 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07001874 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07001875 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001876 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001877 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07001878 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001879 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08001880 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
1881 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001882
1883 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001884 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001885 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001886 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001887
1888 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001889 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001890 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
1891 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
1892
1893 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001894 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001895 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1896 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00001897 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06001898 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001899
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001900 skip |= validate_flags(
1901 "vkCreateGraphicsPipelines",
1902 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1903 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02001904 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001905
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001906 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001907 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001908 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
1909 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
1910
1911 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001912 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001913 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
1914 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
1915
1916 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001917 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
1918 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
1919 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
1920 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001921 }
John Zulauf7acac592017-11-06 11:15:53 -07001922 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001923 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001924 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
1925 "vkCreateGraphicsPipelines(): parameter "
1926 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
1927 i);
John Zulauf7acac592017-11-06 11:15:53 -07001928 }
1929 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
1930 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
1931 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001932 skip |= LogError(
1933 device,
1934
Dave Houlton413a6782018-05-22 13:01:54 -06001935 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001936 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07001937 }
1938 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001939
1940 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
1941 pCreateInfos[i].pRasterizationState->pNext);
1942
1943 if (line_state) {
1944 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
1945 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
1946 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
1947 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001948 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1949 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1950 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
1951 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001952 }
1953 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
1954 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001955 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1956 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1957 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
1958 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001959 }
1960 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
1961 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001962 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1963 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1964 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
1965 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001966 }
1967 }
1968 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
1969 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
1970 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001971 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
1972 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
1973 "range [1,256].",
1974 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001975 }
1976 }
1977 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07001978 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001979 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1980 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001981 skip |=
1982 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
1983 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1984 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
1985 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001986 }
1987 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1988 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001989 skip |=
1990 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
1991 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1992 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
1993 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001994 }
1995 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1996 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001997 skip |=
1998 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
1999 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2000 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2001 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002002 }
2003 if (line_state->stippledLineEnable) {
2004 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2005 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002006 skip |=
2007 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2008 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2009 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2010 "stippledRectangularLines feature.",
2011 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002012 }
2013 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2014 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002015 skip |=
2016 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2017 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2018 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2019 "stippledBresenhamLines feature.",
2020 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002021 }
2022 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2023 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002024 skip |=
2025 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2026 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2027 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2028 "stippledSmoothLines feature.",
2029 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002030 }
2031 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2032 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002033 skip |=
2034 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2035 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2036 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2037 "stippledRectangularLines and strictLines features.",
2038 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002039 }
2040 }
2041 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002042 }
2043
Petr Krause91f7a12017-12-14 20:57:36 +01002044 bool uses_color_attachment = false;
2045 bool uses_depthstencil_attachment = false;
2046 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002047 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002048 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2049 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002050 const auto &subpasses_uses = subpasses_uses_it->second;
2051 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
2052 uses_color_attachment = true;
2053 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
2054 uses_depthstencil_attachment = true;
2055 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002056 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002057 }
2058
2059 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002060 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002061 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002062 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002063 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002064 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002065
2066 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002067 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002068 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002069 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002070
2071 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002072 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002073 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2074 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2075
2076 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002077 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002078 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2079 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2080
2081 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002082 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002083 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2084 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002085 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002086
2087 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002088 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002089 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2090 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2091
2092 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002093 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002094 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2095 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2096
2097 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002098 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002099 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2100 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002101 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002102
2103 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002104 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002105 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2106 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002107 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002108
2109 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002110 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002111 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2112 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002113 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002114
2115 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002116 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002117 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2118 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002119 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002120
2121 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002122 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002123 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2124 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002125 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002126
2127 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002128 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002129 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2130 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002131 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002132
2133 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002134 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002135 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2136 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002137 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002138
2139 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002140 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002141 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2142 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002143 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002144
2145 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002146 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2147 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2148 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2149 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002150 }
2151 }
2152
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002153 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2154 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2155
Petr Krause91f7a12017-12-14 20:57:36 +01002156 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002157 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2158 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2159 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2160 pCreateInfos[i].pColorBlendState,
2161 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2162 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2163
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002164 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002165 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002166 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2167 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2168 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002169 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002170 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2171 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002172
2173 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002174 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002175 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002176 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002177
2178 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002179 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002180 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2181 pCreateInfos[i].pColorBlendState->logicOpEnable);
2182
2183 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002184 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002185 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2186 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002187 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002188 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002189
2190 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2191 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2192 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002193 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002194 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2195 ParameterName::IndexVector{i, attachmentIndex}),
2196 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2197
2198 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002199 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002200 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2201 ParameterName::IndexVector{i, attachmentIndex}),
2202 "VkBlendFactor", AllVkBlendFactorEnums,
2203 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002204 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002205
2206 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002207 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002208 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2209 ParameterName::IndexVector{i, attachmentIndex}),
2210 "VkBlendFactor", AllVkBlendFactorEnums,
2211 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002212 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002213
2214 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002215 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002216 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2217 ParameterName::IndexVector{i, attachmentIndex}),
2218 "VkBlendOp", AllVkBlendOpEnums,
2219 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002220 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002221
2222 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002223 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002224 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2225 ParameterName::IndexVector{i, attachmentIndex}),
2226 "VkBlendFactor", AllVkBlendFactorEnums,
2227 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002228 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002229
2230 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002231 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002232 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2233 ParameterName::IndexVector{i, attachmentIndex}),
2234 "VkBlendFactor", AllVkBlendFactorEnums,
2235 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002236 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002237
2238 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002239 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002240 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2241 ParameterName::IndexVector{i, attachmentIndex}),
2242 "VkBlendOp", AllVkBlendOpEnums,
2243 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002244 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002245
2246 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002247 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002248 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2249 ParameterName::IndexVector{i, attachmentIndex}),
2250 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2251 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002252 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002253 }
2254 }
2255
2256 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002257 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2258 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2259 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2260 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002261 }
2262
2263 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2264 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2265 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002266 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002267 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002268 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2269 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002270 }
2271 }
2272 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002273
Petr Kraus9752aae2017-11-24 03:05:50 +01002274 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2275 if (pCreateInfos[i].basePipelineIndex != -1) {
2276 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002277 skip |=
2278 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
2279 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineHandle, must be "
2280 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
2281 "and pCreateInfos->basePipelineIndex is not -1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002282 }
2283 }
2284
Petr Kraus9752aae2017-11-24 03:05:50 +01002285 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2286 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002287 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
2288 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineIndex, must be -1 if "
2289 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
2290 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002291 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002292 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002293 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002294 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2295 "vkCreateGraphicsPipelines parameter pCreateInfos->basePipelineIndex (%d) must be a valid"
2296 "index into the pCreateInfos array, of size %d.",
2297 pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002298 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002299 }
2300 }
2301
Petr Kraus9752aae2017-11-24 03:05:50 +01002302 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002303 if (!device_extensions.vk_nv_fill_rectangle) {
2304 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2305 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002306 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2307 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2308 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2309 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002310 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2311 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002312 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2313 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2314 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2315 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002316 }
2317 } else {
2318 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2319 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2320 (physical_device_features.fillModeNonSolid == false)) {
2321 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002322 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2323 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2324 "pCreateInfos->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2325 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002326 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002327 }
Petr Kraus299ba622017-11-24 03:09:03 +01002328
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002329 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002330 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002331 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2332 "The line width state is static (pCreateInfos[%" PRIu32
2333 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2334 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2335 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2336 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002337 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002338 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002339 }
2340 }
2341
2342 return skip;
2343}
2344
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002345bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2346 uint32_t createInfoCount,
2347 const VkComputePipelineCreateInfo *pCreateInfos,
2348 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002349 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002350 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002351 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002352 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002353 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002354 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002355 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2356 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002357 skip |=
2358 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2359 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2360 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2361 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002362 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002363
2364 // Make sure compute stage is selected
2365 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002366 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2367 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2368 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002369 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002370 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002371 return skip;
2372}
2373
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002374bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002375 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002376 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002377
2378 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002379 const auto &features = physical_device_features;
2380 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002381
John Zulauf71968502017-10-26 13:51:15 -06002382 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2383 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002384 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2385 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2386 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2387 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002388 }
2389
2390 // Anistropy cannot be enabled in sampler unless enabled as a feature
2391 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002392 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2393 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2394 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002395 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002396 }
John Zulauf71968502017-10-26 13:51:15 -06002397
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002398 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2399 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002400 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2401 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2402 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2403 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002404 }
2405 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002406 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2407 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2408 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2409 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002410 }
2411 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002412 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2413 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2414 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2415 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002416 }
2417 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2418 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2419 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2420 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002421 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2422 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2423 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2424 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2425 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2426 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002427 }
2428 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002429 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2430 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2431 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002432 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002433 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002434 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2435 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2436 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002437 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002438 }
2439
2440 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2441 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002442 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2443 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002444 }
2445
2446 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2447 // valid VkBorderColor value
2448 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2449 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2450 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002451 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2452 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002453 }
2454
2455 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2456 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002457 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002458 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2459 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2460 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002461 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002462 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2463 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2464 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002465 }
John Zulauf275805c2017-10-26 15:34:49 -06002466
2467 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002468 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002469 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2470 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002471 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2472 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2473 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002474 }
2475 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002476
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002477 // Check for valid Lod range
2478 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002479 skip |=
2480 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2481 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002482 }
2483
2484 // Check mipLodBias to device limit
2485 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002486 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2487 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2488 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002489 }
2490
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002491 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2492 if (sampler_conversion != nullptr) {
2493 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2494 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2495 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2496 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002497 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002498 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002499 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2500 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2501 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2502 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2503 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2504 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2505 }
2506 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002507 }
2508
2509 return skip;
2510}
2511
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002512bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2513 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2514 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002515 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002516 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002517
2518 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2519 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2520 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2521 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002522 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2523 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2524 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2525 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2526 ++descriptor_index) {
2527 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07002528 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002529 "vkCreateDescriptorSetLayout: required parameter "
2530 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2531 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002532 }
2533 }
2534 }
2535
2536 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2537 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2538 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002539 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2540 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2541 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2542 "values.",
2543 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002544 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07002545
2546 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
2547 (pCreateInfo->pBindings[i].stageFlags != 0) &&
2548 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
2549 skip |=
2550 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
2551 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
2552 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
2553 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
2554 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
2555 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002556 }
2557 }
2558 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002559 return skip;
2560}
2561
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002562bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2563 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002564 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002565 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2566 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2567 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002568 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2569 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002570}
2571
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002572bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2573 const VkWriteDescriptorSet *pDescriptorWrites,
2574 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002575 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002576
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002577 if (pDescriptorWrites != NULL) {
2578 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2579 // descriptorCount must be greater than 0
2580 if (pDescriptorWrites[i].descriptorCount == 0) {
2581 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002582 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2583 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002584 }
2585
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002586 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2587 if (validateDstSet) {
2588 // dstSet must be a valid VkDescriptorSet handle
2589 skip |= validate_required_handle(vkCallingFunction,
2590 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2591 pDescriptorWrites[i].dstSet);
2592 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002593
2594 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2595 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2596 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2597 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2598 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2599 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2600 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05002601 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
2602 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002603 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002604 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2605 "%s(): if pDescriptorWrites[%d].descriptorType is "
2606 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2607 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2608 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2609 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002610 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2611 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05002612 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
2613 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002614 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2615 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002616 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002617 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2618 ParameterName::IndexVector{i, descriptor_index}),
2619 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002620 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002621 }
2622 }
2623 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2624 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2625 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2626 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2627 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2628 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2629 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05002630 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002631 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002632 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2633 "%s(): if pDescriptorWrites[%d].descriptorType is "
2634 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2635 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2636 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2637 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002638 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05002639 const auto *robustness2_features =
2640 lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
2641 if (robustness2_features && robustness2_features->nullDescriptor) {
2642 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount;
2643 ++descriptorIndex) {
2644 if (pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer == VK_NULL_HANDLE &&
2645 (pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset != 0 ||
2646 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range != VK_WHOLE_SIZE)) {
2647 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
2648 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
2649 "offset (" PRIu64 ") must be zero and range (" PRIu64 ") must be VK_WHOLE_SIZE.",
2650 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset,
2651 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range);
2652 }
2653 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002654 }
2655 }
2656 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2657 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05002658 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002659 }
2660
2661 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2662 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002663 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002664 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2665 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2666 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002667 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002668 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2669 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2670 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2671 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002672 }
2673 }
2674 }
2675 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2676 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002677 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002678 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2679 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2680 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002681 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002682 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
2683 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2684 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2685 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002686 }
2687 }
2688 }
2689 }
sourav parmara96ab1a2020-04-25 16:28:23 -07002690 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
2691 // or VkWriteDescriptorSetInlineUniformBlockEX
2692 if (pDescriptorWrites[i].pNext) {
2693 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
2694 const auto *pNext_struct =
2695 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
2696 if (!pNext_struct || (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
2697 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
2698 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
2699 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
2700 "accelerationStructureCount %d member equals descriptorCount %d.",
2701 vkCallingFunction, pNext_struct ? pNext_struct->accelerationStructureCount : -1,
2702 pDescriptorWrites[i].descriptorCount);
2703 }
2704 // further checks only if we have right structtype
2705 if (pNext_struct) {
2706 if (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
2707 skip |= LogError(
2708 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
2709 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
2710 ".",
2711 vkCallingFunction, pNext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
2712 }
2713 if (pNext_struct->accelerationStructureCount == 0) {
2714 skip |= LogError(
2715 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
2716 "%s(): accelerationStructureCount must be greater than 0 .");
2717 }
2718 }
2719 }
2720 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002721 }
2722 }
2723 return skip;
2724}
2725
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002726bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
2727 const VkWriteDescriptorSet *pDescriptorWrites,
2728 uint32_t descriptorCopyCount,
2729 const VkCopyDescriptorSet *pDescriptorCopies) const {
2730 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
2731}
2732
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002733bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002734 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002735 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002736 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
2737}
2738
2739bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002740 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002741 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002742 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
2743}
2744
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002745bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
2746 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002747 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002748 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002749
2750 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2751 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2752 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002753 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
2754 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002755 return skip;
2756}
2757
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002758bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002759 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002760 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02002761
2762 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
2763 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002764 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
2765
Petr Krause7bb9e82019-08-11 21:34:43 +02002766 // Implicit VUs
2767 // validate only sType here; pointer has to be validated in core_validation
2768 const bool kNotRequired = false;
2769 const char *kNoVUID = nullptr;
2770 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
2771 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
2772 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002773
Petr Krause7bb9e82019-08-11 21:34:43 +02002774 if (pInfo) {
2775 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
2776 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
2777 skip |= validate_struct_pnext(
2778 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
2779 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08002780 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
2781 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002782
Petr Krause7bb9e82019-08-11 21:34:43 +02002783 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002784
Petr Krause7bb9e82019-08-11 21:34:43 +02002785 // Explicit VUs
2786 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002787 skip |= LogError(
2788 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02002789 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
2790 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002791 }
Petr Krause7bb9e82019-08-11 21:34:43 +02002792
2793 if (physical_device_features.inheritedQueries) {
2794 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002795 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06002796 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02002797 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02002798 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002799 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02002800 }
2801
2802 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02002803 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002804 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002805 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02002806 } else { // !pipelineStatisticsQuery
2807 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
2808 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002809 }
Petr Kraus139757b2019-08-15 17:19:33 +02002810
2811 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
2812 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002813 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02002814 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
2815 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002816 skip |= LogError(
2817 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02002818 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
2819 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
2820 }
2821 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002822 }
2823
2824 return skip;
2825}
2826
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002827bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002828 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002829 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002830
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002831 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01002832 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002833 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
2834 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
2835 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01002836 }
2837 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002838 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
2839 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
2840 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01002841 }
2842 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01002843 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002844 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002845 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
2846 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2847 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2848 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002849 }
2850 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01002851
2852 if (pViewports) {
2853 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
2854 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002855 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002856 skip |= manual_PreCallValidateViewport(
2857 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01002858 }
2859 }
2860
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002861 return skip;
2862}
2863
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002864bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002865 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002866 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002867
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002868 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002869 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002870 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
2871 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
2872 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002873 }
2874 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002875 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
2876 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
2877 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002878 }
2879 } else { // multiViewport enabled
2880 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002881 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002882 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
2883 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2884 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2885 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002886 }
2887 }
2888
Petr Kraus6260f0a2018-02-27 21:15:55 +01002889 if (pScissors) {
2890 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
2891 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002892
Petr Kraus6260f0a2018-02-27 21:15:55 +01002893 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002894 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2895 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
2896 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002897 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002898
Petr Kraus6260f0a2018-02-27 21:15:55 +01002899 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002900 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2901 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
2902 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002903 }
2904
2905 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2906 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002907 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
2908 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2909 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2910 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002911 }
2912
2913 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2914 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002915 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
2916 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2917 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2918 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002919 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002920 }
2921 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01002922
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002923 return skip;
2924}
2925
Jeff Bolz5c801d12019-10-09 10:38:45 -05002926bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01002927 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01002928
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002929 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002930 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
2931 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002932 }
2933
2934 return skip;
2935}
2936
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002937bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002938 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002939 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002940 if (vertexCount == 0) {
2941 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
2942 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002943 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002944 }
2945
2946 if (instanceCount == 0) {
2947 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
2948 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002949 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002950 }
2951 return skip;
2952}
2953
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002954bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002955 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002956 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002957
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002958 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002959 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2960 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002961 }
2962 return skip;
2963}
2964
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002965bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002966 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002967 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002968 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002969 skip |=
2970 LogError(device, kVUID_PVError_DeviceFeature,
2971 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002972 }
2973 return skip;
2974}
2975
sfricke-samsungf692b972020-05-02 08:00:45 -07002976bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
2977 VkDeviceSize countBufferOffset, bool khr) const {
2978 bool skip = false;
2979 const char *apiName = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
2980 if (offset & 3) {
2981 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
2982 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
2983 }
2984
2985 if (countBufferOffset & 3) {
2986 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
2987 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
2988 countBufferOffset);
2989 }
2990 return skip;
2991}
2992
2993bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
2994 VkDeviceSize offset, VkBuffer countBuffer,
2995 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
2996 uint32_t stride) const {
2997 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
2998}
2999
3000bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3001 VkDeviceSize offset, VkBuffer countBuffer,
3002 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3003 uint32_t stride) const {
3004 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3005}
3006
3007bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3008 VkDeviceSize countBufferOffset, bool khr) const {
3009 bool skip = false;
3010 const char *apiName = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
3011 if (offset & 3) {
3012 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
3013 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3014 }
3015
3016 if (countBufferOffset & 3) {
3017 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
3018 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3019 countBufferOffset);
3020 }
3021 return skip;
3022}
3023
3024bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3025 VkDeviceSize offset, VkBuffer countBuffer,
3026 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3027 uint32_t stride) const {
3028 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3029}
3030
3031bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3032 VkDeviceSize offset, VkBuffer countBuffer,
3033 VkDeviceSize countBufferOffset,
3034 uint32_t maxDrawCount, uint32_t stride) const {
3035 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3036}
3037
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003038bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3039 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003040 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003041 bool skip = false;
3042 for (uint32_t rect = 0; rect < rectCount; rect++) {
3043 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003044 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3045 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003046 }
sfricke-samsung10867682020-04-25 02:20:39 -07003047 if (pRects[rect].rect.extent.width == 0) {
3048 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3049 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3050 }
3051 if (pRects[rect].rect.extent.height == 0) {
3052 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3053 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3054 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003055 }
3056 return skip;
3057}
3058
Andrew Fobel3abeb992020-01-20 16:33:22 -05003059bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3060 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3061 VkImageFormatProperties2 *pImageFormatProperties,
3062 const char *apiName) const {
3063 bool skip = false;
3064
3065 if (pImageFormatInfo != nullptr) {
3066 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
3067 if (image_stencil_struct != nullptr) {
3068 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3069 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3070 // No flags other than the legal attachment bits may be set
3071 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3072 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003073 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3074 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3075 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3076 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3077 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003078 }
3079 }
3080 }
3081 }
3082
3083 return skip;
3084}
3085
3086bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3087 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3088 VkImageFormatProperties2 *pImageFormatProperties) const {
3089 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3090 "vkGetPhysicalDeviceImageFormatProperties2");
3091}
3092
3093bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3094 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3095 VkImageFormatProperties2 *pImageFormatProperties) const {
3096 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3097 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3098}
3099
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003100bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3101 VkImageLayout srcImageLayout, VkImage dstImage,
3102 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003103 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003104 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003105
Dave Houltonf5217612018-02-02 16:18:52 -07003106 VkImageAspectFlags legal_aspect_flags =
3107 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 -07003108 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003109 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3110 }
3111
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003112 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003113 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003114 skip |= LogError(
3115 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003116 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003117 }
Dave Houltonf5217612018-02-02 16:18:52 -07003118 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003119 skip |= LogError(
3120 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003121 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003122 }
3123 }
3124 return skip;
3125}
3126
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003127bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3128 VkImageLayout srcImageLayout, VkImage dstImage,
3129 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003130 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003131 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003132
Dave Houltonf5217612018-02-02 16:18:52 -07003133 VkImageAspectFlags legal_aspect_flags =
3134 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 -07003135 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003136 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3137 }
3138
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003139 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003140 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003141 skip |= LogError(
3142 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003143 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
3144 }
Dave Houltonf5217612018-02-02 16:18:52 -07003145 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003146 skip |= LogError(
3147 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003148 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
3149 }
3150 }
3151 return skip;
3152}
3153
sfricke-samsung3999ef62020-02-09 17:05:59 -08003154bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3155 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3156 bool skip = false;
3157
3158 if (pRegions != nullptr) {
3159 for (uint32_t i = 0; i < regionCount; i++) {
3160 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003161 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3162 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003163 }
3164 }
3165 }
3166 return skip;
3167}
3168
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003169bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
3170 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003171 uint32_t regionCount,
3172 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003173 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003174
Dave Houltonf5217612018-02-02 16:18:52 -07003175 VkImageAspectFlags legal_aspect_flags =
3176 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 -07003177 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003178 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3179 }
3180
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003181 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003182 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003183 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
3184 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
3185 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003186 }
3187 }
3188 return skip;
3189}
3190
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003191bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
3192 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003193 uint32_t regionCount,
3194 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003195 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003196
Dave Houltonf5217612018-02-02 16:18:52 -07003197 VkImageAspectFlags legal_aspect_flags =
3198 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 -07003199 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003200 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3201 }
3202
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003203 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003204 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Petr Kraus3e6cd032020-04-14 20:41:16 +02003205 skip |= LogError(
3206 device, kVUID_PVError_UnrecognizedValue,
3207 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
3208 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003209 }
3210 }
3211 return skip;
3212}
3213
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003214bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003215 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3216 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003217 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003218
3219 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003220 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3221 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3222 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003223 }
3224
3225 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003226 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3227 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3228 "), must be greater than zero and less than or equal to 65536.",
3229 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003230 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003231 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3232 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3233 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003234 }
3235 return skip;
3236}
3237
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003238bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003239 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003240 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003241
3242 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003243 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3244 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3245 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003246 }
3247
3248 if (size != VK_WHOLE_SIZE) {
3249 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003250 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003251 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3252 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003253 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003254 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3255 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003256 }
3257 }
3258 return skip;
3259}
3260
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003261bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003262 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003263 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003264 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003265
3266 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003267 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3268 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3269 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3270 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003271 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3272 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3273 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003274 }
3275
3276 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3277 // queueFamilyIndexCount uint32_t values
3278 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003279 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3280 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3281 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3282 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003283 }
3284 }
3285
Dave Houlton413a6782018-05-22 13:01:54 -06003286 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003287 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003288 }
3289
3290 return skip;
3291}
3292
Jeff Bolz5c801d12019-10-09 10:38:45 -05003293bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003294 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003295
3296 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003297 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3298 if (present_regions) {
3299 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003300 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003301 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3302 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003303 skip |= LogError(device, kVUID_PVError_InvalidUsage,
3304 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3305 "extension swapchainCount is %i. These values must be equal.",
3306 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003307 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003308 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003309 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3310 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003311 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3312 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3313 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003314 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003315 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003316 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003317 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003318 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003319 }
3320 }
3321
3322 return skip;
3323}
3324
3325#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003326bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3327 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3328 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003329 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003330 bool skip = false;
3331
3332 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003333 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3334 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003335 }
3336
3337 return skip;
3338}
3339#endif // VK_USE_PLATFORM_WIN32_KHR
3340
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003341bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003342 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003343 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003344 bool skip = false;
3345
3346 if (pCreateInfo) {
3347 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003348 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3349 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003350 }
3351
3352 if (pCreateInfo->pPoolSizes) {
3353 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3354 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003355 skip |= LogError(
3356 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003357 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003358 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003359 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3360 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003361 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3362 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3363 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3364 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3365 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003366 }
Petr Krausc8655be2017-09-27 18:56:51 +02003367 }
3368 }
3369 }
3370
3371 return skip;
3372}
3373
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003374bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003375 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003376 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003377
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003378 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003379 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003380 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3381 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3382 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003383 }
3384
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003385 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003386 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003387 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3388 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3389 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003390 }
3391
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003392 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003393 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003394 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3395 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3396 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003397 }
3398
3399 return skip;
3400}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003401
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003402bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003403 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003404 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003405
3406 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003407 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3408 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003409 }
3410 return skip;
3411}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003412
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003413bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3414 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003415 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003416 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003417
3418 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003419 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003420 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003421 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3422 "vkCmdDispatch(): baseGroupX (%" PRIu32
3423 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3424 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003425 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003426 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3427 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3428 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3429 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003430 }
3431
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003432 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003433 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003434 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3435 "vkCmdDispatch(): baseGroupY (%" PRIu32
3436 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3437 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003438 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003439 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3440 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3441 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3442 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003443 }
3444
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003445 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003446 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003447 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3448 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3449 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3450 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003451 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003452 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3453 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3454 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3455 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003456 }
3457
3458 return skip;
3459}
3460
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003461bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3462 VkPipelineBindPoint pipelineBindPoint,
3463 VkPipelineLayout layout, uint32_t set,
3464 uint32_t descriptorWriteCount,
3465 const VkWriteDescriptorSet *pDescriptorWrites) const {
3466 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3467}
3468
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003469bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3470 uint32_t firstExclusiveScissor,
3471 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003472 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003473 bool skip = false;
3474
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003475 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003476 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003477 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003478 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3479 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3480 ") is not 0.",
3481 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003482 }
3483 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003484 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003485 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3486 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3487 ") is not 1.",
3488 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003489 }
3490 } else { // multiViewport enabled
3491 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003492 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003493 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3494 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3495 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3496 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003497 }
3498 }
3499
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003500 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003501 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3502 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3503 ") must be less than maxViewports (=%" PRIu32 ").",
3504 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003505 }
3506
3507 if (pExclusiveScissors) {
3508 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3509 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3510
3511 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003512 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3513 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3514 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003515 }
3516
3517 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003518 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3519 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3520 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003521 }
3522
3523 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3524 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003525 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3526 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3527 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3528 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003529 }
3530
3531 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3532 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003533 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3534 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3535 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3536 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003537 }
3538 }
3539 }
3540
3541 return skip;
3542}
3543
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003544bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3545 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003546 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003547 bool skip = false;
3548 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003549 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3550 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3551 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003552 } else {
3553 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3554 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003555 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3556 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3557 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3558 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003559 }
3560 }
3561
3562 return skip;
3563}
3564
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003565bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3566 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003567 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003568 bool skip = false;
3569
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003570 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003571 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003572 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003573 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3574 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3575 ") is not 0.",
3576 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003577 }
3578 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003579 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003580 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3581 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3582 ") is not 1.",
3583 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003584 }
3585 }
3586
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003587 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003588 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3589 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3590 ") must be less than maxViewports (=%" PRIu32 ").",
3591 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003592 }
3593
3594 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003595 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003596 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3597 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3598 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3599 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003600 }
3601
3602 return skip;
3603}
3604
Jeff Bolz5c801d12019-10-09 10:38:45 -05003605bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3606 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3607 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003608 bool skip = false;
3609
Dave Houlton142c4cb2018-10-17 15:04:41 -06003610 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003611 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3612 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3613 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003614 }
3615
3616 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003617 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003618 }
3619
3620 return skip;
3621}
3622
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003623bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003624 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003625 bool skip = false;
3626
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003627 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003628 skip |= LogError(
3629 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003630 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3631 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003632 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003633 }
3634
3635 return skip;
3636}
3637
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003638bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3639 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003640 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003641 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003642 static const int condition_multiples = 0b0011;
3643 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003644 skip |= LogError(
3645 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003646 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003647 }
Lockee1c22882019-06-10 16:02:54 -06003648 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003649 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3650 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3651 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3652 stride);
Lockee1c22882019-06-10 16:02:54 -06003653 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003654 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003655 skip |= LogError(
3656 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3657 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003658 }
3659
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003660 return skip;
3661}
3662
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003663bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3664 VkDeviceSize offset, VkBuffer countBuffer,
3665 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003666 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003667 bool skip = false;
3668
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003669 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003670 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3671 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3672 "), is not a multiple of 4.",
3673 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003674 }
3675
3676 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003677 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
3678 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3679 "), is not a multiple of 4.",
3680 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003681 }
3682
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003683 return skip;
3684}
3685
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003686bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003687 const VkAllocationCallbacks *pAllocator,
3688 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003689 bool skip = false;
3690
3691 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3692 if (pCreateInfo != nullptr) {
3693 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3694 // VkQueryPipelineStatisticFlagBits values
3695 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3696 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003697 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
3698 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3699 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3700 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003701 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07003702 if (pCreateInfo->queryCount == 0) {
3703 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
3704 "vkCreateQueryPool(): queryCount must be greater than zero.");
3705 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003706 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003707 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003708}
3709
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003710bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3711 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003712 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003713 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3714 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003715}
3716
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003717void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003718 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3719 VkResult result) {
3720 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003721 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003722}
3723
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003724void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003725 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3726 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003727 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003728 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003729 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003730}
3731
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003732void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
3733 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003734 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003735 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003736 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003737}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003738
3739bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003740 const VkAllocationCallbacks *pAllocator,
3741 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003742 bool skip = false;
3743
3744 if (pAllocateInfo) {
3745 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
3746 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003747 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
3748 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003749 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003750
3751 VkMemoryAllocateFlags flags = 0;
3752 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
3753 if (flags_info) {
3754 flags = flags_info->flags;
3755 }
3756
3757 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
3758 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
3759 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003760 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
3761 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
3762 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003763 }
3764
3765#ifdef VK_USE_PLATFORM_WIN32_KHR
3766 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
3767#endif
3768 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
3769 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
3770#ifdef VK_USE_PLATFORM_ANDROID_KHR
3771 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
3772#endif
3773
3774 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003775 skip |= LogError(
3776 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003777 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
3778 }
3779 if (
3780#ifdef VK_USE_PLATFORM_WIN32_KHR
3781 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
3782#endif
3783 (import_memory_fd && import_memory_fd->handleType) ||
3784#ifdef VK_USE_PLATFORM_ANDROID_KHR
3785 (import_memory_ahb && import_memory_ahb->buffer) ||
3786#endif
3787 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003788 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
3789 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003790 }
3791 }
3792
3793 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003794 VkBool32 capture_replay = false;
3795 VkBool32 buffer_device_address = false;
3796 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
3797 if (vulkan_12_features) {
3798 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
3799 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
3800 } else {
3801 const auto *bda_features =
3802 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
3803 if (bda_features) {
3804 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
3805 buffer_device_address = bda_features->bufferDeviceAddress;
3806 }
3807 }
3808 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003809 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
3810 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
3811 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003812 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003813 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003814 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
3815 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003816 }
3817 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003818 }
3819 return skip;
3820}
Ricardo Garciaa4935972019-02-21 17:43:18 +01003821
Jason Macnak192fa0e2019-07-26 15:07:16 -07003822bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003823 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003824 bool skip = false;
3825
3826 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
3827 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
3828 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003829 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003830 } else {
3831 uint32_t vertex_component_size = 0;
3832 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
3833 vertex_component_size = 4;
3834 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
3835 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
3836 vertex_component_size = 2;
3837 }
3838 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003839 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003840 }
3841 }
3842
3843 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
3844 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003845 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003846 } else {
3847 uint32_t index_element_size = 0;
3848 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
3849 index_element_size = 4;
3850 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
3851 index_element_size = 2;
3852 }
3853 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003854 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003855 }
3856 }
3857 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
3858 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003859 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003860 }
3861 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003862 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003863 }
3864 }
3865
3866 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003867 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003868 }
3869
3870 return skip;
3871}
3872
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003873bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
3874 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003875 bool skip = false;
3876
3877 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003878 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003879 }
3880 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003881 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003882 }
3883
3884 return skip;
3885}
3886
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003887bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
3888 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003889 bool skip = false;
3890 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003891 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003892 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003893 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003894 }
3895 return skip;
3896}
3897
3898bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003899 VkAccelerationStructureNV object_handle,
Jason Macnak192fa0e2019-07-26 15:07:16 -07003900 const char *func_name) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003901 bool skip = false;
3902 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003903 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
3904 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
3905 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003906 }
3907 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003908 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
3909 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
3910 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003911 }
3912 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
3913 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003914 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
3915 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
3916 "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 -07003917 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003918 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003919 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
3920 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
3921 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003922 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003923 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003924 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
3925 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
3926 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003927 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003928 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07003929 uint64_t total_triangle_count = 0;
3930 for (uint32_t i = 0; i < info.geometryCount; i++) {
3931 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07003932
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003933 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003934
Jason Macnak5c954952019-07-09 15:46:12 -07003935 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
3936 continue;
3937 }
3938 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
3939 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003940 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003941 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
3942 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
3943 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003944 }
3945 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003946 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
3947 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
3948 for (uint32_t i = 1; i < info.geometryCount; i++) {
3949 const VkGeometryNV &geometry = info.pGeometries[i];
3950 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003951 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003952 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
3953 "info.pGeometries[0].geometryType.",
3954 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07003955 }
3956 }
3957 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003958 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
3959 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
3960 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
3961 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
3962 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
3963 "or VK_GEOMETRY_TYPE_AABBS_NV.");
3964 }
3965 }
3966 skip |=
3967 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
3968 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-03486");
Jason Macnak5c954952019-07-09 15:46:12 -07003969 return skip;
3970}
3971
Ricardo Garciaa4935972019-02-21 17:43:18 +01003972bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
3973 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003974 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01003975 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01003976 if (pCreateInfo) {
3977 if ((pCreateInfo->compactedSize != 0) &&
3978 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003979 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
3980 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
3981 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
3982 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01003983 }
Jason Macnak5c954952019-07-09 15:46:12 -07003984
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003985 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
Jason Macnak192fa0e2019-07-26 15:07:16 -07003986 "vkCreateAccelerationStructureNV()");
Ricardo Garciaa4935972019-02-21 17:43:18 +01003987 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01003988 return skip;
3989}
Mike Schuchardt21638df2019-03-16 10:52:02 -07003990
Jeff Bolz5c801d12019-10-09 10:38:45 -05003991bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
3992 const VkAccelerationStructureInfoNV *pInfo,
3993 VkBuffer instanceData, VkDeviceSize instanceOffset,
3994 VkBool32 update, VkAccelerationStructureNV dst,
3995 VkAccelerationStructureNV src, VkBuffer scratch,
3996 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003997 bool skip = false;
3998
3999 if (pInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004000 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()");
Jason Macnak5c954952019-07-09 15:46:12 -07004001 }
4002
4003 return skip;
4004}
4005
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004006bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4007 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4008 VkAccelerationStructureKHR *pAccelerationStructure) const {
4009 bool skip = false;
4010
4011 if (pCreateInfo) {
4012 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
4013 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4014 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4015 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
4016 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
4017 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4018 i);
4019 }
4020 }
4021
4022 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4023 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4024 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
4025 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
4026 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4027 i);
4028 }
4029 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004030 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
4031 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
4032 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
4033 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
4034 skip |= LogError(
4035 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
4036 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
4037 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
4038 }
4039 }
4040 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
4041 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
4042 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
4043 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4044 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
4045 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
4046 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
4047 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
4048 }
4049 }
4050 }
4051
4052 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
4053 pCreateInfo->maxGeometryCount != 1) {
4054 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
4055 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4056 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004057 }
4058
4059 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
4060 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
4061 skip |= LogError(
4062 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
4063 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
4064 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
4065 }
4066
4067 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
4068 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
4069 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
4070 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
4071 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
4072 }
4073
4074 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
4075 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
4076 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
4077 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
4078 if (geometry_type != first_geometry_type) {
4079 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
4080 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
4081 "pGeometryInfos[0].geometryType.",
4082 i);
4083 }
4084 }
4085 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004086 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
4087 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
4088 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
4089 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
4090 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
4091 "maxGeometryCount %d.",
4092 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
4093 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004094 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004095 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4096 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
4097 if (pCreateInfo->deviceAddress != 0) {
4098 skip |=
4099 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
4100 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
4101 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
4102 }
4103 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004104 return skip;
4105}
4106
Jason Macnak5c954952019-07-09 15:46:12 -07004107bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4108 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004109 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004110 bool skip = false;
4111 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004112 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4113 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004114 }
4115 return skip;
4116}
4117
Peter Chen85366392019-05-14 15:20:11 -04004118bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4119 uint32_t createInfoCount,
4120 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4121 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004122 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004123 bool skip = false;
4124
4125 for (uint32_t i = 0; i < createInfoCount; i++) {
4126 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4127 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004128 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4129 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4130 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4131 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4132 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004133 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004134
4135 const auto *pipeline_cache_contol_features =
4136 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4137 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4138 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4139 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4140 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4141 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4142 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4143 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4144 }
4145 }
4146
sourav parmarf4a78252020-04-10 13:04:21 -07004147 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4148 skip |=
4149 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4150 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4151 }
4152 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4153 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4154 skip |=
4155 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4156 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4157 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4158 }
4159 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4160 if (pCreateInfos[i].basePipelineIndex != -1) {
4161 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4162 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4163 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4164 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4165 "and pCreateInfos->basePipelineIndex is not -1.");
4166 }
4167 }
4168 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4169 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4170 skip |=
4171 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4172 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4173 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4174 "commands pCreateInfos parameter.");
4175 }
4176 } else {
4177 if (pCreateInfos[i].basePipelineIndex != -1) {
4178 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4179 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4180 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4181 }
4182 }
4183 }
4184 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4185 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4186 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4187 }
4188 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4189 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4190 "vkCreateRayTracingPipelinesNV: flags must not include "
4191 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4192 }
4193 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4194 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4195 "vkCreateRayTracingPipelinesNV: flags must not include "
4196 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4197 }
4198 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4199 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4200 "vkCreateRayTracingPipelinesNV: flags must not include "
4201 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4202 }
4203 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4204 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4205 "vkCreateRayTracingPipelinesNV: flags must not include "
4206 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4207 }
4208 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4209 skip |= LogError(
4210 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4211 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4212 }
4213 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4214 skip |= LogError(
4215 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4216 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4217 }
Peter Chen85366392019-05-14 15:20:11 -04004218 }
4219
4220 return skip;
4221}
4222
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004223bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4224 uint32_t createInfoCount,
4225 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4226 const VkAllocationCallbacks *pAllocator,
4227 VkPipeline *pPipelines) const {
4228 bool skip = false;
4229
4230 for (uint32_t i = 0; i < createInfoCount; i++) {
4231 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4232 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4233 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4234 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4235 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4236 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4237 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4238 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004239 const auto *pipeline_cache_contol_features =
4240 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4241 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4242 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4243 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4244 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4245 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4246 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4247 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4248 }
4249 }
4250 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4251 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4252 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4253 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4254 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4255 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4256 }
4257 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4258 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4259 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4260 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4261 }
4262 }
4263
sourav parmarf4a78252020-04-10 13:04:21 -07004264 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4265 skip |=
4266 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4267 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4268 }
4269 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4270 if (pCreateInfos[i].pLibraryInterface == NULL)
4271 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4272 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4273 }
4274 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4275 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4276 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4277 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4278 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4279 skip |= LogError(
4280 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4281 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4282 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4283 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4284 "must not be VK_SHADER_UNUSED_KHR");
4285 }
4286 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4287 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4288 skip |= LogError(
4289 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4290 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4291 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4292 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4293 "element must not be VK_SHADER_UNUSED_KHR");
4294 }
4295 }
4296 }
4297 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4298 if (pCreateInfos[i].basePipelineIndex != -1) {
4299 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4300 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4301 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4302 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4303 "and pCreateInfos->basePipelineIndex is not -1.");
4304 }
4305 }
4306 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4307 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4308 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4309 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4310 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4311 "commands pCreateInfos parameter %d.",
4312 pCreateInfos[i].basePipelineIndex, createInfoCount);
4313 }
4314 } else {
4315 if (pCreateInfos[i].basePipelineIndex != -1) {
4316 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4317 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4318 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4319 }
4320 }
4321 }
4322 if (pCreateInfos[i].libraries.libraryCount == 0) {
4323 if (pCreateInfos[i].stageCount == 0) {
4324 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4325 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4326 }
4327 if (pCreateInfos[i].groupCount == 0) {
4328 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4329 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4330 }
4331 } else {
4332 if (pCreateInfos[i].pLibraryInterface == NULL) {
4333 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4334 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4335 }
4336 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004337 }
4338
4339 return skip;
4340}
4341
Mike Schuchardt21638df2019-03-16 10:52:02 -07004342#ifdef VK_USE_PLATFORM_WIN32_KHR
4343bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4344 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004345 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004346 bool skip = false;
4347 if (!device_extensions.vk_khr_swapchain)
4348 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4349 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4350 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4351 if (!device_extensions.vk_khr_surface)
4352 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4353 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4354 skip |=
4355 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4356 if (!device_extensions.vk_ext_full_screen_exclusive)
4357 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4358 skip |= validate_struct_type(
4359 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4360 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4361 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4362 if (pSurfaceInfo != NULL) {
4363 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4364 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4365 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4366
4367 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4368 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4369 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4370 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004371 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4372 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004373
4374 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4375 }
4376 return skip;
4377}
4378#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004379
4380bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4381 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004382 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004383 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4384 bool skip = false;
4385 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4386 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4387 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4388 }
4389 return skip;
4390}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004391
4392bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004393 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004394 bool skip = false;
4395
4396 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004397 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4398 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004399 }
4400
4401 return skip;
4402}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004403
4404bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004405 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004406 bool skip = false;
4407
4408 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004409 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4410 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004411 }
4412
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004413 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06004414 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004415 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4416 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004417 }
4418
4419 return skip;
4420}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004421
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004422bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4423 uint32_t bindingCount, const VkBuffer *pBuffers,
4424 const VkDeviceSize *pOffsets) const {
4425 bool skip = false;
4426 if (firstBinding > device_limits.maxVertexInputBindings) {
4427 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4428 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4429 device_limits.maxVertexInputBindings);
4430 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4431 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4432 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4433 "maxVertexInputBindings (%u)",
4434 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4435 }
4436
Jeff Bolz165818a2020-05-08 11:19:03 -05004437 for (uint32_t i = 0; i < bindingCount; ++i) {
4438 if (pBuffers[i] == VK_NULL_HANDLE) {
4439 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
4440 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
4441 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
4442 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
4443 } else {
4444 if (pOffsets[i] != 0) {
4445 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
4446 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
4447 }
4448 }
4449 }
4450 }
4451
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004452 return skip;
4453}
4454
Mark Lobodzinski84988402019-09-11 15:27:30 -06004455bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004456 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004457 bool skip = false;
4458 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004459 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4460 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004461 }
4462 return skip;
4463}
4464
4465bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004466 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004467 bool skip = false;
4468 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004469 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4470 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004471 }
4472 return skip;
4473}
Petr Kraus3d720392019-11-13 02:52:39 +01004474
4475bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4476 VkSemaphore semaphore, VkFence fence,
4477 uint32_t *pImageIndex) const {
4478 bool skip = false;
4479
4480 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004481 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4482 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004483 }
4484
4485 return skip;
4486}
4487
4488bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4489 uint32_t *pImageIndex) const {
4490 bool skip = false;
4491
4492 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004493 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4494 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004495 }
4496
4497 return skip;
4498}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004499
4500bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
4501 uint32_t firstInstance, VkBuffer counterBuffer,
4502 VkDeviceSize counterBufferOffset,
4503 uint32_t counterOffset, uint32_t vertexStride) const {
4504 bool skip = false;
4505
4506 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004507 skip |= LogError(
4508 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004509 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
4510 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
4511 }
4512
4513 return skip;
4514}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004515
4516bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
4517 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4518 const VkAllocationCallbacks *pAllocator,
4519 VkSamplerYcbcrConversion *pYcbcrConversion,
4520 const char *apiName) const {
4521 bool skip = false;
4522
4523 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004524 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004525 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004526 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
4527 "samplerYcbcrConversion must be enabled to call %s.", apiName);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004528 }
4529 return skip;
4530}
4531
4532bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
4533 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4534 const VkAllocationCallbacks *pAllocator,
4535 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4536 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4537 "vkCreateSamplerYcbcrConversion");
4538}
4539
4540bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
4541 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4542 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4543 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4544 "vkCreateSamplerYcbcrConversionKHR");
4545}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004546
4547bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
4548 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
4549 bool skip = false;
4550 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
4551 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
4552
4553 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004554 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
4555 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
4556 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
4557 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
4558 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004559 }
4560 return skip;
4561}
sourav parmara96ab1a2020-04-25 16:28:23 -07004562
4563bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
4564 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4565 bool skip = false;
4566 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4567 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4568 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4569 }
4570 return skip;
4571}
4572
4573bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
4574 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4575 bool skip = false;
4576 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4577 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
4578 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4579 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4580 }
4581 return skip;
4582}
4583
4584bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
4585 const char *api_name) const {
4586 bool skip = false;
4587 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
4588 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
4589 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
4590 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
4591 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
4592 api_name);
4593 }
4594 return skip;
4595}
4596
4597bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
4598 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4599 bool skip = false;
4600 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
4601 return skip;
4602}
4603
4604bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
4605 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4606 bool skip = false;
4607 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
4608 return skip;
4609}
4610
4611bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
4612 const char *api_name) const {
4613 bool skip = false;
4614 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
4615 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
4616 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
4617 }
4618 return skip;
4619}
4620
4621bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
4622 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4623 bool skip = false;
4624 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()");
4625 return skip;
4626}
4627bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
4628 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4629 bool skip = false;
4630 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()");
4631 return skip;
4632}