blob: 792f982f2f0beb6dd398e690eb21c3952b5d896a [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
253 auto vertex_attribute_divisor_features =
254 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
255 if (vertex_attribute_divisor_features) {
256 bool extension_found = false;
257 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
258 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
259 VK_MAX_EXTENSION_NAME_SIZE)) {
260 extension_found = true;
261 break;
262 }
263 }
264 if (!extension_found) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700265 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
266 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
267 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600268 }
269 }
270
Tony-LunarG28017bc2020-01-23 14:40:25 -0700271 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
272 if (vulkan_11_features) {
273 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
274 while (current) {
275 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
276 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
277 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
278 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
279 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
280 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700281 skip |= LogError(
282 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700283 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
284 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
285 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
286 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
287 break;
288 }
289 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
290 }
291 }
292
293 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
294 if (vulkan_12_features) {
295 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
296 while (current) {
297 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
298 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
299 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
300 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
301 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
302 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
303 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
304 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
305 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
306 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
307 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
308 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
309 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700310 skip |= LogError(
311 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700312 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
313 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
314 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
315 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
316 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
317 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
318 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
319 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
320 break;
321 }
322 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
323 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700324 // Check features are enabled if matching extension is passed in as well
325 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
326 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
327 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
328 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
329 skip |= LogError(
330 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
331 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
332 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
333 }
334 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
335 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
336 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
337 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
338 "is not VK_TRUE.",
339 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
340 }
341 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
342 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
343 skip |= LogError(
344 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
345 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
346 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
347 }
348 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
349 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
350 skip |= LogError(
351 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
352 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
353 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
354 }
355 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
356 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
357 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
358 skip |=
359 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
360 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
361 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
362 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
363 }
364 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700365 }
366
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600367 // Validate pCreateInfo->pQueueCreateInfos
368 if (pCreateInfo->pQueueCreateInfos) {
369 std::unordered_set<uint32_t> set;
370
371 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700372 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
373 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600374 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700375 skip |=
376 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
377 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
378 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
379 "index value.",
380 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600381 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700382 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
383 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
384 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
385 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600386 } else {
387 set.insert(requested_queue_family);
388 }
389
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700390 if (queue_create_info.pQueuePriorities != nullptr) {
391 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
392 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600393 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700394 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
395 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
396 "] (=%f) is not between 0 and 1 (inclusive).",
397 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600398 }
399 }
400 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700401
402 // Need to know if protectedMemory feature is passed in preCall to creating the device
403 VkBool32 protectedMemory = VK_FALSE;
404 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
405 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
406 if (protected_features) {
407 protectedMemory = protected_features->protectedMemory;
408 } else if (vulkan_11_features) {
409 protectedMemory = vulkan_11_features->protectedMemory;
410 }
411 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) {
412 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
413 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
414 "protectedMemory feature being set as well.");
415 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600416 }
417 }
418
419 return skip;
420}
421
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500422bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700423 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700424 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
425 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
426 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600427 }
428
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700429 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600430}
431
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700432bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500433 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100434 bool skip = false;
435
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600436 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700437 skip |=
438 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600439
440 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
441 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
442 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
443 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700444 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
445 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
446 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600447 }
448
449 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
450 // queueFamilyIndexCount uint32_t values
451 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700452 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
453 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
454 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
455 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600456 }
457 }
458
459 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
460 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
461 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
462 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700463 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
464 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
465 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600466 }
467 }
468
469 return skip;
470}
471
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700472bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500473 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600474 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600475
476 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600477 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
478 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
479 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
480 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700481 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
482 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
483 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600484 }
485
486 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
487 // queueFamilyIndexCount uint32_t values
488 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700489 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
490 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
491 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
492 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600493 }
494 }
495
Dave Houlton413a6782018-05-22 13:01:54 -0600496 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700497 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600498 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700499 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600500 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700501 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600502
Dave Houlton413a6782018-05-22 13:01:54 -0600503 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700504 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600505 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700506 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600507
Dave Houlton130c0212018-01-29 13:39:56 -0700508 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700509 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
510 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700511 skip |= LogError(
512 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600513 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
514 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700515 }
516
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600517 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100518 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
519 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700520 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
521 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
522 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600523 }
524
525 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100526 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
527 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700528 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
529 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
530 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
531 ") are not equal.",
532 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100533 }
534
535 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700536 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
537 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
538 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
539 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100540 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600541 }
542
543 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700544 skip |= LogError(
545 device, "VUID-VkImageCreateInfo-imageType-00957",
546 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600547 }
548 }
549
Dave Houlton130c0212018-01-29 13:39:56 -0700550 // 3D image may have only 1 layer
551 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700552 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
553 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700554 }
555
556 // If multi-sample, validate type, usage, tiling and mip levels.
557 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
558 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600559 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700560 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
561 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700562 }
563
564 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
565 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
566 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
567 // At least one of the legal attachment bits must be set
568 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700569 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
570 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700571 }
572 // No flags other than the legal attachment bits may be set
573 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
574 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700575 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
576 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700577 }
578 }
579
Jeff Bolzef40fec2018-09-01 22:04:34 -0500580 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600581 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500582 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600583 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
584 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500585 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600586 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700587 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
588 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
589 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600590 }
591
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600592 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700593 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
594 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
595 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600596 }
597
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700598 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700599 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
600 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
601 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100602 }
603
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600604 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
605 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
606 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
607 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700608 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
609 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
610 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600611 }
612
613 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
614 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
615 // Linear tiling is unsupported
616 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700617 skip |= LogError(device, kVUID_PVError_InvalidUsage,
618 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
619 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600620 }
621
622 // Sparse 1D image isn't valid
623 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700624 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
625 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600626 }
627
628 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700629 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700630 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
631 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
632 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600633 }
634
635 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700636 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700637 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
638 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
639 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600640 }
641
642 // Multi-sample 2D image when device doesn't support it
643 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700644 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600645 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700646 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
647 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
648 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700649 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600650 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700651 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
652 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
653 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700654 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600655 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700656 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
657 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
658 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700659 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600660 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700661 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
662 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
663 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600664 }
665 }
666 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500667
Jeff Bolz9af91c52018-09-01 21:53:57 -0500668 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
669 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700670 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
671 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
672 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500673 }
674 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700675 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
676 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
677 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500678 }
679 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700680 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
681 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
682 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500683 }
684 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500685
686 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600687 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700688 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
689 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
690 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500691 }
692
Dave Houlton142c4cb2018-10-17 15:04:41 -0600693 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700694 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
695 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
696 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
697 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500698 }
699
Dave Houlton142c4cb2018-10-17 15:04:41 -0600700 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700701 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
702 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
703 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
704 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500705 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600706 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700707 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
708 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
709 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
710 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500711 }
712 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500713
sfricke-samsung8f658d42020-05-03 20:12:24 -0700714 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
715 (FormatHasDepth(pCreateInfo->format) == false)) {
716 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
717 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
718 "format must be a depth or depth/stencil format.");
719 }
720
Andrew Fobel3abeb992020-01-20 16:33:22 -0500721 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
722 if (image_stencil_struct != nullptr) {
723 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
724 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
725 // No flags other than the legal attachment bits may be set
726 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
727 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700728 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
729 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
730 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
731 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500732 }
733 }
734
735 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
736 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
737 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
738 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700739 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
740 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
741 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
742 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500743 }
744
745 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
746 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700747 LogError(device, "VUID-VkImageCreateInfo-format-02537",
748 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
749 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
750 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500751 }
752 }
753
754 if (!physical_device_features.shaderStorageImageMultisample &&
755 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
756 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
757 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700758 LogError(device, "VUID-VkImageCreateInfo-format-02538",
759 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
760 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
761 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500762 }
763
764 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
765 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700766 skip |= LogError(
767 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500768 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
769 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
770 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
771 } else 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-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500775 "vkCreateImage(): Depth-stencil image in which usage does not include "
776 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
777 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
778 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
779 }
780
781 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
782 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700783 skip |= LogError(
784 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500785 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
786 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
787 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
788 } else 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-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500792 "vkCreateImage(): Depth-stencil image in which usage does not include "
793 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
794 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
795 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
796 }
797 }
798 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700799
800 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
801 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
802 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
803 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
804 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
805 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700806
807 if (device_extensions.vk_ext_image_drm_format_modifier) {
808 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
809 const auto drm_format_mod_explict =
810 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
811 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
812 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
813 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
814 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
815 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
816 "either VkImageDrmFormatModifierListCreateInfoEXT or "
817 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
818 }
819 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
820 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
821 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
822 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
823 "in the pNext chain");
824 }
825 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600826 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500827
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600828 return skip;
829}
830
Jeff Bolz99e3f632020-03-24 22:59:22 -0500831bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
832 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
833 bool skip = false;
834
835 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700836 // Validate feature set if using CUBE_ARRAY
837 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
838 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
839 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
840 "enabling the imageCubeArray feature.");
841 }
842
Jeff Bolz99e3f632020-03-24 22:59:22 -0500843 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
844 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
845 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -0700846 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -0500847 pCreateInfo->subresourceRange.layerCount);
848 }
849 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700850 skip |= LogError(
851 device, "VUID-VkImageViewCreateInfo-viewType-02961",
852 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
853 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -0500854 }
855 }
856 }
857 return skip;
858}
859
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600860bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700861 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100862 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100863
864 // Note: for numerical correctness
865 // - float comparisons should expect NaN (comparison always false).
866 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
867
868 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -0700869 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100870 if (v1_f <= 0.0f) return true;
871
872 float intpart;
873 const float fract = modff(v1_f, &intpart);
874
875 assert(std::numeric_limits<float>::radix == 2);
876 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
877 if (intpart >= u32_max_plus1) return false;
878
879 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
880 if (v1_u32 < v2_u32)
881 return true;
882 else if (v1_u32 == v2_u32 && fract == 0.0f)
883 return true;
884 else
885 return false;
886 };
887
888 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
889 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
890 return (v1_f <= v2_f);
891 };
892
893 // width
894 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700895 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100896
897 if (!(viewport.width > 0.0f)) {
898 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700899 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
900 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100901 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
902 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700903 skip |= LogError(object, "VUID-VkViewport-width-01771",
904 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
905 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100906 } 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 -0700907 skip |= LogWarning(object, kVUID_PVError_NONE,
908 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
909 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
910 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100911 }
912
913 // height
914 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -0700915 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700916 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100917
918 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
919 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700920 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
921 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100922 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
923 height_healthy = false;
924
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700925 skip |= LogError(object, "VUID-VkViewport-height-01773",
926 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
927 ").",
928 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
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 |= LogWarning(
933 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +0100934 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600935 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600936 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100937 }
938
939 // x
940 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700941 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100942 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700943 skip |= LogError(object, "VUID-VkViewport-x-01774",
944 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
945 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100946 }
947
948 // x + width
949 if (x_healthy && width_healthy) {
950 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700951 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700952 skip |= LogError(
953 object, "VUID-VkViewport-x-01232",
954 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
955 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
956 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100957 }
958 }
959
960 // y
961 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700962 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100963 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700964 skip |= LogError(object, "VUID-VkViewport-y-01775",
965 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
966 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700967 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100968 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700969 skip |= LogError(object, "VUID-VkViewport-y-01776",
970 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
971 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100972 }
973
974 // y + height
975 if (y_healthy && height_healthy) {
976 const float boundary = viewport.y + viewport.height;
977
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700978 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700979 skip |= LogError(object, "VUID-VkViewport-y-01233",
980 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
981 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
982 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700983 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600984 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700985 LogError(object, "VUID-VkViewport-y-01777",
986 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
987 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
988 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100989 }
990 }
991
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700992 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100993 // minDepth
994 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700995 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600996
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700997 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
998 "[0.0, 1.0] range.",
999 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001000 }
1001
1002 // maxDepth
1003 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001004 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001005
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001006 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1007 "[0.0, 1.0] range.",
1008 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001009 }
1010 }
1011
1012 return skip;
1013}
1014
Dave Houlton142c4cb2018-10-17 15:04:41 -06001015struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001016 VkShadingRatePaletteEntryNV shadingRate;
1017 uint32_t width;
1018 uint32_t height;
1019};
1020
1021// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -06001022static SampleOrderInfo sampleOrderInfos[] = {
1023 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1024 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1025 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1026 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1027 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1028 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001029};
1030
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001031bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001032 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001033
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001034 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001035 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001036 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001037 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001038 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001039 break;
1040 }
1041 }
1042
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001043 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001044 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1045 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1046 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001047 return skip;
1048 }
1049
Dave Houlton142c4cb2018-10-17 15:04:41 -06001050 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001051 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001052 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1053 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1054 ") must "
1055 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1056 "is set in framebufferNoAttachmentsSampleCounts.",
1057 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001058 }
1059
Jeff Bolz9af91c52018-09-01 21:53:57 -05001060 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001061 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1062 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1063 ") must "
1064 "be equal to the product of sampleCount (=%" PRIu32
1065 "), the fragment width for shadingRate "
1066 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1067 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001068 }
1069
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001070 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001071 skip |= LogError(
1072 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001073 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1074 ") must "
1075 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001076 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001077 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001078
1079 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001080 // the first width*height*sampleCount bits to all be set. Note: There is no
1081 // guarantee that 64 bits is enough, but practically it's unlikely for an
1082 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001083 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001084 uint64_t sampleLocationsMask = 0;
1085 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1086 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1087 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001088 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1089 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001090 }
1091 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001092 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1093 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001094 }
1095 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001096 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1097 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001098 }
1099 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1100 sampleLocationsMask |= 1ULL << idx;
1101 }
1102
1103 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1104 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001105 skip |= LogError(
1106 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001107 "The array pSampleLocations must contain exactly one entry for "
1108 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001109 }
1110
1111 return skip;
1112}
1113
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001114bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1115 uint32_t createInfoCount,
1116 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1117 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001118 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001119 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001120
1121 if (pCreateInfos != nullptr) {
1122 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001123 bool has_dynamic_viewport = false;
1124 bool has_dynamic_scissor = false;
1125 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001126 bool has_dynamic_depth_bias = false;
1127 bool has_dynamic_blend_constant = false;
1128 bool has_dynamic_depth_bounds = false;
1129 bool has_dynamic_stencil_compare = false;
1130 bool has_dynamic_stencil_write = false;
1131 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001132 bool has_dynamic_viewport_w_scaling_nv = false;
1133 bool has_dynamic_discard_rectangle_ext = false;
1134 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001135 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001136 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001137 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001138 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001139 if (pCreateInfos[i].pDynamicState != nullptr) {
1140 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1141 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1142 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001143 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1144 if (has_dynamic_viewport == true) {
1145 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1146 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1147 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1148 i);
1149 }
1150 has_dynamic_viewport = true;
1151 }
1152 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1153 if (has_dynamic_scissor == true) {
1154 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1155 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1156 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1157 i);
1158 }
1159 has_dynamic_scissor = true;
1160 }
1161 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1162 if (has_dynamic_line_width == true) {
1163 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1164 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1165 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1166 i);
1167 }
1168 has_dynamic_line_width = true;
1169 }
1170 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1171 if (has_dynamic_depth_bias == true) {
1172 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1173 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1174 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1175 i);
1176 }
1177 has_dynamic_depth_bias = true;
1178 }
1179 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1180 if (has_dynamic_blend_constant == true) {
1181 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1182 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1183 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1184 i);
1185 }
1186 has_dynamic_blend_constant = true;
1187 }
1188 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1189 if (has_dynamic_depth_bounds == true) {
1190 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1191 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1192 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1193 i);
1194 }
1195 has_dynamic_depth_bounds = true;
1196 }
1197 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1198 if (has_dynamic_stencil_compare == true) {
1199 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1200 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1201 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1202 i);
1203 }
1204 has_dynamic_stencil_compare = true;
1205 }
1206 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1207 if (has_dynamic_stencil_write == true) {
1208 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1209 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1210 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1211 i);
1212 }
1213 has_dynamic_stencil_write = true;
1214 }
1215 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1216 if (has_dynamic_stencil_reference == true) {
1217 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1218 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1219 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1220 i);
1221 }
1222 has_dynamic_stencil_reference = true;
1223 }
1224 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1225 if (has_dynamic_viewport_w_scaling_nv == true) {
1226 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1227 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1228 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1229 i);
1230 }
1231 has_dynamic_viewport_w_scaling_nv = true;
1232 }
1233 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1234 if (has_dynamic_discard_rectangle_ext == true) {
1235 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1236 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1237 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1238 i);
1239 }
1240 has_dynamic_discard_rectangle_ext = true;
1241 }
1242 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1243 if (has_dynamic_sample_locations_ext == true) {
1244 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1245 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1246 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1247 i);
1248 }
1249 has_dynamic_sample_locations_ext = true;
1250 }
1251 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1252 if (has_dynamic_exclusive_scissor_nv == true) {
1253 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1254 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1255 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1256 i);
1257 }
1258 has_dynamic_exclusive_scissor_nv = true;
1259 }
1260 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1261 if (has_dynamic_shading_rate_palette_nv == true) {
1262 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1263 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1264 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1265 i);
1266 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001267 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001268 }
1269 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1270 if (has_dynamic_viewport_course_sample_order_nv == true) {
1271 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1272 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1273 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1274 i);
1275 }
1276 has_dynamic_viewport_course_sample_order_nv = true;
1277 }
1278 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1279 if (has_dynamic_line_stipple == true) {
1280 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1281 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1282 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1283 i);
1284 }
1285 has_dynamic_line_stipple = true;
1286 }
Petr Kraus299ba622017-11-24 03:09:03 +01001287 }
1288 }
1289
Peter Chen85366392019-05-14 15:20:11 -04001290 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1291 if ((feedback_struct != nullptr) &&
1292 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001293 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1294 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1295 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1296 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1297 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001298 }
1299
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001300 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001301
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001302 // Collect active stages and other information
1303 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001304 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001305 bool has_eval = false;
1306 bool has_control = false;
1307 if (pCreateInfos[i].pStages != nullptr) {
1308 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1309 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1310
1311 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1312 has_control = true;
1313 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1314 has_eval = true;
1315 }
1316
1317 skip |= validate_string(
1318 "vkCreateGraphicsPipelines",
1319 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1320 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1321 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001322 }
1323
1324 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1325 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1326 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1327 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1328 pCreateInfos[i].pTessellationState,
1329 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1330 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1331
1332 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1333 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1334
1335 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1336 "VkPipelineTessellationDomainOriginStateCreateInfo",
1337 pCreateInfos[i].pTessellationState->pNext,
1338 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1339 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001340 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1341 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001342
1343 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1344 pCreateInfos[i].pTessellationState->flags,
1345 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1346 }
1347
1348 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1349 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1350 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1351 pCreateInfos[i].pInputAssemblyState,
1352 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1353 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1354
1355 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1356 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001357 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001358
1359 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1360 pCreateInfos[i].pInputAssemblyState->flags,
1361 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1362
1363 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1364 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1365 pCreateInfos[i].pInputAssemblyState->topology,
1366 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1367
1368 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1369 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1370 }
1371
1372 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001373 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001374
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001375 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001376 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1377 "vkCreateGraphicsPipelines: pararameter "
1378 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1379 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001380 }
1381
1382 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1383 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1384 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1385 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1386 pCreateInfos[i].pVertexInputState->pNext, 1,
1387 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001388 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1389 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001390 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1391 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001392 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001393 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1394 skip |=
1395 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1396 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1397 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1398 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1399 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1400
1401 skip |= validate_array(
1402 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1403 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1404 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1405 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1406
1407 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1408 for (uint32_t vertexBindingDescriptionIndex = 0;
1409 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1410 ++vertexBindingDescriptionIndex) {
1411 skip |= validate_ranged_enum(
1412 "vkCreateGraphicsPipelines",
1413 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1414 AllVkVertexInputRateEnums,
1415 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1416 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1417 }
1418 }
1419
1420 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1421 for (uint32_t vertexAttributeDescriptionIndex = 0;
1422 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1423 ++vertexAttributeDescriptionIndex) {
1424 skip |= validate_ranged_enum(
1425 "vkCreateGraphicsPipelines",
1426 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1427 AllVkFormatEnums,
1428 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1429 "VUID-VkVertexInputAttributeDescription-format-parameter");
1430 }
1431 }
1432
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001433 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001434 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1435 "vkCreateGraphicsPipelines: pararameter "
1436 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1437 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1438 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001439 }
1440
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001441 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001442 skip |=
1443 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1444 "vkCreateGraphicsPipelines: pararameter "
1445 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1446 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1447 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001448 }
1449
1450 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001451 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1452 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001453 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1454 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001455 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1456 "vkCreateGraphicsPipelines: parameter "
1457 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1458 "(%" PRIu32 ") is not distinct.",
1459 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001460 }
1461 vertex_bindings.insert(vertex_bind_desc.binding);
1462
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001463 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001464 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1465 "vkCreateGraphicsPipelines: parameter "
1466 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1467 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1468 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001469 }
1470
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001471 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001472 skip |=
1473 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1474 "vkCreateGraphicsPipelines: parameter "
1475 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1476 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1477 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001478 }
1479 }
1480
Peter Kohautc7d9d392018-07-15 00:34:07 +02001481 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001482 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1483 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001484 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1485 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001486 skip |= LogError(
1487 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001488 "vkCreateGraphicsPipelines: parameter "
1489 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1490 i, d, vertex_attrib_desc.location);
1491 }
1492 attribute_locations.insert(vertex_attrib_desc.location);
1493
1494 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1495 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001496 skip |= LogError(
1497 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001498 "vkCreateGraphicsPipelines: parameter "
1499 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1500 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1501 i, d, vertex_attrib_desc.binding, i);
1502 }
1503
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001504 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001505 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1506 "vkCreateGraphicsPipelines: parameter "
1507 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1508 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1509 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001510 }
1511
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001512 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001513 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1514 "vkCreateGraphicsPipelines: parameter "
1515 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1516 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1517 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001518 }
1519
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001520 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001521 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1522 "vkCreateGraphicsPipelines: parameter "
1523 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1524 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1525 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001526 }
1527 }
1528 }
1529
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001530 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1531 if (has_control && has_eval) {
1532 if (pCreateInfos[i].pTessellationState == nullptr) {
1533 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1534 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1535 "shader stage and a tessellation evaluation shader stage, "
1536 "pCreateInfos[%d].pTessellationState must not be NULL.",
1537 i, i);
1538 } else {
1539 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1540 skip |= validate_struct_pnext(
1541 "vkCreateGraphicsPipelines",
1542 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1543 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1544 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1545 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001546
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001547 skip |= validate_reserved_flags(
1548 "vkCreateGraphicsPipelines",
1549 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1550 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001551
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001552 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1553 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1554 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1555 "vkCreateGraphicsPipelines: invalid parameter "
1556 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1557 "should be >0 and <=%u.",
1558 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1559 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001560 }
1561 }
1562 }
1563
1564 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1565 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1566 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1567 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001568 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1569 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1570 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1571 "].pViewportState (=NULL) is not a valid pointer.",
1572 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001573 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001574 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1575
1576 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001577 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1578 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1579 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1580 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001581 }
1582
Petr Krausa6103552017-11-16 21:21:58 +01001583 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1584 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001585 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1586 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001587 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1588 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001589 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001590 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001591 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001592 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001593 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001594 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1595 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001596 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001597 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1598 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001599
1600 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001601 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001602 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001603 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001604
Dave Houlton142c4cb2018-10-17 15:04:41 -06001605 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1606 pCreateInfos[i].pViewportState->pNext);
1607 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1608 pCreateInfos[i].pViewportState->pNext);
1609 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1610 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001611 const auto vp_swizzle_struct =
1612 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001613 const auto vp_w_scaling_struct =
1614 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001615
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001616 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001617 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001618 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1619 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1620 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1621 ") is not 1.",
1622 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001623 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001624
Petr Krausa6103552017-11-16 21:21:58 +01001625 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001626 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1627 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1628 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1629 ") is not 1.",
1630 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001631 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001632
Dave Houlton142c4cb2018-10-17 15:04:41 -06001633 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1634 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001635 skip |= LogError(
1636 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1637 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1638 "disabled, but pCreateInfos[%" PRIu32
1639 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1640 ") is not 1.",
1641 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001642 }
1643
Jeff Bolz9af91c52018-09-01 21:53:57 -05001644 if (shading_rate_image_struct &&
1645 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001646 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
1647 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1648 "disabled, but pCreateInfos[%" PRIu32
1649 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
1650 ") is neither 0 nor 1.",
1651 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001652 }
1653
Petr Krausa6103552017-11-16 21:21:58 +01001654 } else { // multiViewport enabled
1655 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001656 skip |= LogError(
1657 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001658 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001659 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001660 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
1661 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1662 "].pViewportState->viewportCount (=%" PRIu32
1663 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1664 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001665 }
Petr Krausa6103552017-11-16 21:21:58 +01001666
1667 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001668 skip |= LogError(
1669 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001670 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001671 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001672 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
1673 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1674 "].pViewportState->scissorCount (=%" PRIu32
1675 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1676 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001677 }
1678 }
1679
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001680 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001681 skip |=
1682 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1683 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1684 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1685 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001686 }
1687
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001688 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001689 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1690 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1691 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1692 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1693 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001694 }
1695
Petr Krausa6103552017-11-16 21:21:58 +01001696 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001697 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
1698 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1699 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1700 "].pViewportState->viewportCount (=%" PRIu32 ").",
1701 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001702 }
1703
Dave Houlton142c4cb2018-10-17 15:04:41 -06001704 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001705 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001706 skip |=
1707 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1708 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1709 ") must be zero or identical to pCreateInfos[%" PRIu32
1710 "].pViewportState->viewportCount (=%" PRIu32 ").",
1711 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001712 }
1713
Dave Houlton142c4cb2018-10-17 15:04:41 -06001714 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001715 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001716 skip |= LogError(
1717 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001718 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1719 "] "
1720 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1721 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1722 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001723 }
1724
Petr Krausa6103552017-11-16 21:21:58 +01001725 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001726 skip |= LogError(
1727 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001728 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1729 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001730 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1731 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001732 }
1733
1734 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001735 skip |= LogError(
1736 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001737 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1738 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001739 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1740 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001741 }
1742
Jeff Bolz3e71f782018-08-29 23:15:45 -05001743 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001744 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1745 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1746 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001747 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-pDynamicStates-02030",
1748 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1749 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1750 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1751 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001752 }
1753
Jeff Bolz9af91c52018-09-01 21:53:57 -05001754 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001755 shading_rate_image_struct->viewportCount > 0 &&
1756 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001757 skip |= LogError(
1758 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-pDynamicStates-02057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001759 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001760 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1761 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001762 i, i);
1763 }
1764
Chris Mayer328d8212018-12-11 14:16:18 +01001765 if (vp_swizzle_struct) {
1766 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001767 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
1768 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
1769 " does "
1770 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
1771 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01001772 }
1773 }
1774
Petr Krausb3fcdb42018-01-09 22:09:09 +01001775 // validate the VkViewports
1776 if (!has_dynamic_viewport && viewport_state.pViewports) {
1777 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
1778 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001779 const char *fn_name = "vkCreateGraphicsPipelines";
1780 skip |= manual_PreCallValidateViewport(viewport, fn_name,
1781 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
1782 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001783 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01001784 }
1785 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001786
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001787 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001788 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1789 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1790 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
1791 "VK_NV_clip_space_w_scaling extension is not enabled.",
1792 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001793 }
1794
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001795 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001796 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1797 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1798 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
1799 "VK_EXT_discard_rectangles extension is not enabled.",
1800 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001801 }
1802
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001803 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001804 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1805 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1806 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
1807 "VK_EXT_sample_locations extension is not enabled.",
1808 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001809 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001810
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001811 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001812 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1813 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1814 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
1815 "VK_NV_scissor_exclusive extension is not enabled.",
1816 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001817 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001818
1819 if (coarse_sample_order_struct &&
1820 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
1821 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001822 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
1823 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1824 "] "
1825 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
1826 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
1827 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001828 }
1829
1830 if (coarse_sample_order_struct) {
1831 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001832 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001833 }
1834 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001835
1836 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
1837 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001838 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
1839 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1840 "] "
1841 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
1842 ") "
1843 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
1844 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001845 }
1846 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001847 skip |= LogError(
1848 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001849 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1850 "] "
1851 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
1852 i);
1853 }
1854 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001855 }
1856
1857 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001858 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
1859 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
1860 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
1861 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001862 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07001863 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
1864 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
1865 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07001866 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07001867 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07001868 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001869 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001870 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07001871 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001872 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08001873 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
1874 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001875
1876 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001877 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001878 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001879 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001880
1881 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001882 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001883 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
1884 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
1885
1886 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001887 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001888 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1889 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00001890 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06001891 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001892
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001893 skip |= validate_flags(
1894 "vkCreateGraphicsPipelines",
1895 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1896 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02001897 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001898
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001899 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001900 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001901 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
1902 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
1903
1904 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001905 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001906 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
1907 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
1908
1909 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001910 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
1911 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
1912 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
1913 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001914 }
John Zulauf7acac592017-11-06 11:15:53 -07001915 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001916 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001917 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
1918 "vkCreateGraphicsPipelines(): parameter "
1919 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
1920 i);
John Zulauf7acac592017-11-06 11:15:53 -07001921 }
1922 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
1923 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
1924 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001925 skip |= LogError(
1926 device,
1927
Dave Houlton413a6782018-05-22 13:01:54 -06001928 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001929 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07001930 }
1931 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001932
1933 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
1934 pCreateInfos[i].pRasterizationState->pNext);
1935
1936 if (line_state) {
1937 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
1938 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
1939 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
1940 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001941 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1942 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1943 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
1944 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001945 }
1946 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
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->alphaToOneEnable == VK_TRUE.",
1951 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001952 }
1953 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
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->sampleShadingEnable == VK_TRUE.",
1958 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001959 }
1960 }
1961 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
1962 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
1963 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001964 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
1965 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
1966 "range [1,256].",
1967 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001968 }
1969 }
1970 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07001971 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001972 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1973 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001974 skip |=
1975 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
1976 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1977 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
1978 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001979 }
1980 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1981 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001982 skip |=
1983 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
1984 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1985 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
1986 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001987 }
1988 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1989 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001990 skip |=
1991 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
1992 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1993 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
1994 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001995 }
1996 if (line_state->stippledLineEnable) {
1997 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1998 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001999 skip |=
2000 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2001 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2002 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2003 "stippledRectangularLines feature.",
2004 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002005 }
2006 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2007 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002008 skip |=
2009 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2010 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2011 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2012 "stippledBresenhamLines feature.",
2013 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002014 }
2015 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2016 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002017 skip |=
2018 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2019 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2020 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2021 "stippledSmoothLines feature.",
2022 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002023 }
2024 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2025 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002026 skip |=
2027 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2028 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2029 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2030 "stippledRectangularLines and strictLines features.",
2031 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002032 }
2033 }
2034 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002035 }
2036
Petr Krause91f7a12017-12-14 20:57:36 +01002037 bool uses_color_attachment = false;
2038 bool uses_depthstencil_attachment = false;
2039 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002040 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002041 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2042 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002043 const auto &subpasses_uses = subpasses_uses_it->second;
2044 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
2045 uses_color_attachment = true;
2046 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
2047 uses_depthstencil_attachment = true;
2048 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002049 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002050 }
2051
2052 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002053 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002054 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002055 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002056 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002057 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002058
2059 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002060 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002061 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002062 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002063
2064 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002065 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002066 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2067 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2068
2069 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002070 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002071 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2072 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2073
2074 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002075 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002076 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2077 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002078 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002079
2080 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002081 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002082 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2083 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2084
2085 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002086 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002087 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2088 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2089
2090 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002091 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002092 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2093 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002094 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002095
2096 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002097 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002098 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2099 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002100 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002101
2102 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002103 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002104 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2105 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002106 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002107
2108 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002109 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002110 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2111 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002112 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002113
2114 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002115 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002116 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2117 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002118 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002119
2120 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002121 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002122 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2123 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002124 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002125
2126 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002127 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002128 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2129 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002130 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002131
2132 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002133 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002134 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2135 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002136 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002137
2138 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002139 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2140 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2141 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2142 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002143 }
2144 }
2145
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002146 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2147 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2148
Petr Krause91f7a12017-12-14 20:57:36 +01002149 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002150 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2151 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2152 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2153 pCreateInfos[i].pColorBlendState,
2154 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2155 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2156
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002157 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002158 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002159 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2160 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2161 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002162 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002163 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2164 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002165
2166 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002167 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002168 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002169 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002170
2171 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002172 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002173 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2174 pCreateInfos[i].pColorBlendState->logicOpEnable);
2175
2176 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002177 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002178 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2179 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002180 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002181 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002182
2183 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2184 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2185 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002186 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002187 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2188 ParameterName::IndexVector{i, attachmentIndex}),
2189 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2190
2191 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002192 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002193 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2194 ParameterName::IndexVector{i, attachmentIndex}),
2195 "VkBlendFactor", AllVkBlendFactorEnums,
2196 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002197 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002198
2199 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002200 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002201 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2202 ParameterName::IndexVector{i, attachmentIndex}),
2203 "VkBlendFactor", AllVkBlendFactorEnums,
2204 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002205 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002206
2207 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002208 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002209 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2210 ParameterName::IndexVector{i, attachmentIndex}),
2211 "VkBlendOp", AllVkBlendOpEnums,
2212 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002213 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002214
2215 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002216 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002217 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2218 ParameterName::IndexVector{i, attachmentIndex}),
2219 "VkBlendFactor", AllVkBlendFactorEnums,
2220 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002221 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002222
2223 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002224 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002225 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2226 ParameterName::IndexVector{i, attachmentIndex}),
2227 "VkBlendFactor", AllVkBlendFactorEnums,
2228 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002229 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002230
2231 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002232 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002233 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2234 ParameterName::IndexVector{i, attachmentIndex}),
2235 "VkBlendOp", AllVkBlendOpEnums,
2236 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002237 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002238
2239 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002240 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002241 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2242 ParameterName::IndexVector{i, attachmentIndex}),
2243 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2244 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002245 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002246 }
2247 }
2248
2249 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002250 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2251 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2252 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2253 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002254 }
2255
2256 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2257 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2258 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002259 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002260 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002261 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2262 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002263 }
2264 }
2265 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002266
Petr Kraus9752aae2017-11-24 03:05:50 +01002267 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2268 if (pCreateInfos[i].basePipelineIndex != -1) {
2269 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002270 skip |=
2271 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
2272 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineHandle, must be "
2273 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
2274 "and pCreateInfos->basePipelineIndex is not -1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002275 }
2276 }
2277
Petr Kraus9752aae2017-11-24 03:05:50 +01002278 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2279 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002280 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
2281 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineIndex, must be -1 if "
2282 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
2283 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002284 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002285 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002286 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002287 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2288 "vkCreateGraphicsPipelines parameter pCreateInfos->basePipelineIndex (%d) must be a valid"
2289 "index into the pCreateInfos array, of size %d.",
2290 pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002291 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002292 }
2293 }
2294
Petr Kraus9752aae2017-11-24 03:05:50 +01002295 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002296 if (!device_extensions.vk_nv_fill_rectangle) {
2297 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2298 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002299 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2300 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2301 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2302 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002303 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2304 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002305 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2306 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2307 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2308 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002309 }
2310 } else {
2311 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2312 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2313 (physical_device_features.fillModeNonSolid == false)) {
2314 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002315 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2316 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2317 "pCreateInfos->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2318 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002319 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002320 }
Petr Kraus299ba622017-11-24 03:09:03 +01002321
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002322 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002323 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002324 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2325 "The line width state is static (pCreateInfos[%" PRIu32
2326 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2327 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2328 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2329 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002330 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002331 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002332 }
2333 }
2334
2335 return skip;
2336}
2337
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002338bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2339 uint32_t createInfoCount,
2340 const VkComputePipelineCreateInfo *pCreateInfos,
2341 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002342 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002343 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002344 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002345 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002346 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002347 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002348 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2349 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002350 skip |=
2351 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2352 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2353 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2354 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002355 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002356
2357 // Make sure compute stage is selected
2358 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002359 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2360 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2361 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002362 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002363 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002364 return skip;
2365}
2366
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002367bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002368 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002369 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002370
2371 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002372 const auto &features = physical_device_features;
2373 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002374
John Zulauf71968502017-10-26 13:51:15 -06002375 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2376 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002377 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2378 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2379 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2380 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002381 }
2382
2383 // Anistropy cannot be enabled in sampler unless enabled as a feature
2384 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002385 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2386 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2387 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002388 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002389 }
John Zulauf71968502017-10-26 13:51:15 -06002390
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002391 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2392 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002393 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2394 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2395 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2396 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002397 }
2398 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002399 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2400 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2401 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2402 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002403 }
2404 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002405 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2406 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2407 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2408 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002409 }
2410 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2411 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2412 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2413 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002414 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2415 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2416 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2417 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2418 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2419 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002420 }
2421 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002422 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2423 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2424 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002425 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002426 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002427 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2428 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2429 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002430 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002431 }
2432
2433 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2434 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002435 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2436 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002437 }
2438
2439 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2440 // valid VkBorderColor value
2441 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2442 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2443 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002444 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2445 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002446 }
2447
2448 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2449 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002450 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002451 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2452 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2453 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002454 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002455 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2456 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2457 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002458 }
John Zulauf275805c2017-10-26 15:34:49 -06002459
2460 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002461 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002462 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2463 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002464 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2465 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2466 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002467 }
2468 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002469
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002470 // Check for valid Lod range
2471 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002472 skip |=
2473 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2474 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002475 }
2476
2477 // Check mipLodBias to device limit
2478 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002479 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2480 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2481 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002482 }
2483
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002484 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2485 if (sampler_conversion != nullptr) {
2486 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2487 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2488 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2489 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002490 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002491 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002492 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2493 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2494 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2495 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2496 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2497 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2498 }
2499 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002500 }
2501
2502 return skip;
2503}
2504
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002505bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2506 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2507 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002508 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002509 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002510
2511 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2512 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2513 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2514 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002515 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2516 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2517 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2518 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2519 ++descriptor_index) {
2520 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07002521 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002522 "vkCreateDescriptorSetLayout: required parameter "
2523 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2524 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002525 }
2526 }
2527 }
2528
2529 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2530 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2531 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002532 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2533 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2534 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2535 "values.",
2536 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002537 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07002538
2539 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
2540 (pCreateInfo->pBindings[i].stageFlags != 0) &&
2541 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
2542 skip |=
2543 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
2544 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
2545 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
2546 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
2547 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
2548 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002549 }
2550 }
2551 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002552 return skip;
2553}
2554
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002555bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2556 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002557 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002558 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2559 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2560 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002561 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2562 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002563}
2564
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002565bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2566 const VkWriteDescriptorSet *pDescriptorWrites,
2567 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002568 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002569
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002570 if (pDescriptorWrites != NULL) {
2571 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2572 // descriptorCount must be greater than 0
2573 if (pDescriptorWrites[i].descriptorCount == 0) {
2574 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002575 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2576 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002577 }
2578
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002579 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2580 if (validateDstSet) {
2581 // dstSet must be a valid VkDescriptorSet handle
2582 skip |= validate_required_handle(vkCallingFunction,
2583 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2584 pDescriptorWrites[i].dstSet);
2585 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002586
2587 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2588 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2589 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2590 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2591 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2592 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2593 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2594 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures
2595 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002596 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2597 "%s(): if pDescriptorWrites[%d].descriptorType is "
2598 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2599 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2600 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2601 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002602 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2603 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
2604 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageView and imageLayout
2605 // members of any given element of pImageInfo must be a valid VkImageView and VkImageLayout, respectively
2606 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2607 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002608 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002609 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageView",
2610 ParameterName::IndexVector{i, descriptor_index}),
2611 pDescriptorWrites[i].pImageInfo[descriptor_index].imageView);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002612 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002613 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2614 ParameterName::IndexVector{i, descriptor_index}),
2615 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002616 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002617 }
2618 }
2619 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2620 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2621 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2622 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2623 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2624 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2625 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
2626 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002627 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2628 "%s(): if pDescriptorWrites[%d].descriptorType is "
2629 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2630 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2631 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2632 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002633 } else {
2634 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount; ++descriptorIndex) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002635 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002636 ParameterName("pDescriptorWrites[%i].pBufferInfo[%i].buffer",
2637 ParameterName::IndexVector{i, descriptorIndex}),
2638 pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer);
2639 }
2640 }
2641 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2642 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
2643 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
2644 // pTexelBufferView must be a pointer to an array of descriptorCount valid VkBufferView handles
2645 if (pDescriptorWrites[i].pTexelBufferView == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002646 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00323",
2647 "%s(): if pDescriptorWrites[%d].descriptorType is "
2648 "VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, "
2649 "pDescriptorWrites[%d].pTexelBufferView must not be NULL.",
2650 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002651 } else {
2652 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2653 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002654 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002655 ParameterName("pDescriptorWrites[%i].pTexelBufferView[%i]",
2656 ParameterName::IndexVector{i, descriptor_index}),
2657 pDescriptorWrites[i].pTexelBufferView[descriptor_index]);
2658 }
2659 }
2660 }
2661
2662 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2663 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002664 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002665 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2666 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2667 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002668 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002669 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2670 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2671 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2672 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002673 }
2674 }
2675 }
2676 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2677 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002678 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002679 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2680 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2681 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002682 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002683 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
2684 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2685 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2686 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002687 }
2688 }
2689 }
2690 }
sourav parmara96ab1a2020-04-25 16:28:23 -07002691 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
2692 // or VkWriteDescriptorSetInlineUniformBlockEX
2693 if (pDescriptorWrites[i].pNext) {
2694 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
2695 const auto *pNext_struct =
2696 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
2697 if (!pNext_struct || (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
2698 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
2699 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
2700 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
2701 "accelerationStructureCount %d member equals descriptorCount %d.",
2702 vkCallingFunction, pNext_struct ? pNext_struct->accelerationStructureCount : -1,
2703 pDescriptorWrites[i].descriptorCount);
2704 }
2705 // further checks only if we have right structtype
2706 if (pNext_struct) {
2707 if (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
2708 skip |= LogError(
2709 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
2710 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
2711 ".",
2712 vkCallingFunction, pNext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
2713 }
2714 if (pNext_struct->accelerationStructureCount == 0) {
2715 skip |= LogError(
2716 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
2717 "%s(): accelerationStructureCount must be greater than 0 .");
2718 }
2719 }
2720 }
2721 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002722 }
2723 }
2724 return skip;
2725}
2726
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002727bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
2728 const VkWriteDescriptorSet *pDescriptorWrites,
2729 uint32_t descriptorCopyCount,
2730 const VkCopyDescriptorSet *pDescriptorCopies) const {
2731 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
2732}
2733
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002734bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002735 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002736 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002737 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
2738}
2739
2740bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002741 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002742 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002743 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
2744}
2745
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002746bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
2747 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002748 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002749 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002750
2751 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2752 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2753 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002754 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
2755 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002756 return skip;
2757}
2758
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002759bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002760 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002761 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02002762
2763 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
2764 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002765 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
2766
Petr Krause7bb9e82019-08-11 21:34:43 +02002767 // Implicit VUs
2768 // validate only sType here; pointer has to be validated in core_validation
2769 const bool kNotRequired = false;
2770 const char *kNoVUID = nullptr;
2771 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
2772 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
2773 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002774
Petr Krause7bb9e82019-08-11 21:34:43 +02002775 if (pInfo) {
2776 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
2777 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
2778 skip |= validate_struct_pnext(
2779 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
2780 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08002781 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
2782 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002783
Petr Krause7bb9e82019-08-11 21:34:43 +02002784 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002785
Petr Krause7bb9e82019-08-11 21:34:43 +02002786 // Explicit VUs
2787 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002788 skip |= LogError(
2789 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02002790 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
2791 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002792 }
Petr Krause7bb9e82019-08-11 21:34:43 +02002793
2794 if (physical_device_features.inheritedQueries) {
2795 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002796 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06002797 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02002798 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02002799 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002800 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02002801 }
2802
2803 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02002804 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002805 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002806 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02002807 } else { // !pipelineStatisticsQuery
2808 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
2809 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002810 }
Petr Kraus139757b2019-08-15 17:19:33 +02002811
2812 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
2813 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002814 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02002815 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
2816 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002817 skip |= LogError(
2818 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02002819 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
2820 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
2821 }
2822 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002823 }
2824
2825 return skip;
2826}
2827
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002828bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002829 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002830 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002831
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002832 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01002833 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002834 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
2835 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
2836 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01002837 }
2838 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002839 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
2840 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
2841 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01002842 }
2843 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01002844 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002845 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002846 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
2847 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2848 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2849 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002850 }
2851 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01002852
2853 if (pViewports) {
2854 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
2855 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002856 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002857 skip |= manual_PreCallValidateViewport(
2858 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01002859 }
2860 }
2861
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002862 return skip;
2863}
2864
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002865bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002866 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002867 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002868
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002869 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002870 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002871 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
2872 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
2873 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002874 }
2875 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002876 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
2877 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
2878 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002879 }
2880 } else { // multiViewport enabled
2881 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002882 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002883 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
2884 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2885 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2886 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002887 }
2888 }
2889
Petr Kraus6260f0a2018-02-27 21:15:55 +01002890 if (pScissors) {
2891 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
2892 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002893
Petr Kraus6260f0a2018-02-27 21:15:55 +01002894 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002895 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2896 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
2897 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002898 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002899
Petr Kraus6260f0a2018-02-27 21:15:55 +01002900 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002901 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2902 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
2903 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002904 }
2905
2906 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2907 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002908 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
2909 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2910 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2911 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002912 }
2913
2914 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2915 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002916 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
2917 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2918 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2919 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002920 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002921 }
2922 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01002923
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002924 return skip;
2925}
2926
Jeff Bolz5c801d12019-10-09 10:38:45 -05002927bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01002928 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01002929
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002930 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002931 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
2932 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002933 }
2934
2935 return skip;
2936}
2937
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002938bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002939 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002940 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002941 if (vertexCount == 0) {
2942 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
2943 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002944 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002945 }
2946
2947 if (instanceCount == 0) {
2948 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
2949 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002950 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002951 }
2952 return skip;
2953}
2954
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002955bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002956 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002957 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002958
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002959 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002960 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2961 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002962 }
2963 return skip;
2964}
2965
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002966bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002967 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002968 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002969 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002970 skip |=
2971 LogError(device, kVUID_PVError_DeviceFeature,
2972 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002973 }
2974 return skip;
2975}
2976
sfricke-samsungf692b972020-05-02 08:00:45 -07002977bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
2978 VkDeviceSize countBufferOffset, bool khr) const {
2979 bool skip = false;
2980 const char *apiName = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
2981 if (offset & 3) {
2982 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
2983 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
2984 }
2985
2986 if (countBufferOffset & 3) {
2987 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
2988 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
2989 countBufferOffset);
2990 }
2991 return skip;
2992}
2993
2994bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
2995 VkDeviceSize offset, VkBuffer countBuffer,
2996 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
2997 uint32_t stride) const {
2998 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
2999}
3000
3001bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3002 VkDeviceSize offset, VkBuffer countBuffer,
3003 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3004 uint32_t stride) const {
3005 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3006}
3007
3008bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3009 VkDeviceSize countBufferOffset, bool khr) const {
3010 bool skip = false;
3011 const char *apiName = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
3012 if (offset & 3) {
3013 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
3014 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3015 }
3016
3017 if (countBufferOffset & 3) {
3018 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
3019 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3020 countBufferOffset);
3021 }
3022 return skip;
3023}
3024
3025bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3026 VkDeviceSize offset, VkBuffer countBuffer,
3027 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3028 uint32_t stride) const {
3029 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3030}
3031
3032bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3033 VkDeviceSize offset, VkBuffer countBuffer,
3034 VkDeviceSize countBufferOffset,
3035 uint32_t maxDrawCount, uint32_t stride) const {
3036 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3037}
3038
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003039bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3040 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003041 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003042 bool skip = false;
3043 for (uint32_t rect = 0; rect < rectCount; rect++) {
3044 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003045 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3046 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003047 }
sfricke-samsung10867682020-04-25 02:20:39 -07003048 if (pRects[rect].rect.extent.width == 0) {
3049 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3050 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3051 }
3052 if (pRects[rect].rect.extent.height == 0) {
3053 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3054 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3055 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003056 }
3057 return skip;
3058}
3059
Andrew Fobel3abeb992020-01-20 16:33:22 -05003060bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3061 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3062 VkImageFormatProperties2 *pImageFormatProperties,
3063 const char *apiName) const {
3064 bool skip = false;
3065
3066 if (pImageFormatInfo != nullptr) {
3067 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
3068 if (image_stencil_struct != nullptr) {
3069 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3070 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3071 // No flags other than the legal attachment bits may be set
3072 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3073 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003074 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3075 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3076 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3077 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3078 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003079 }
3080 }
3081 }
3082 }
3083
3084 return skip;
3085}
3086
3087bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3088 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3089 VkImageFormatProperties2 *pImageFormatProperties) const {
3090 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3091 "vkGetPhysicalDeviceImageFormatProperties2");
3092}
3093
3094bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3095 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3096 VkImageFormatProperties2 *pImageFormatProperties) const {
3097 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3098 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3099}
3100
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003101bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3102 VkImageLayout srcImageLayout, VkImage dstImage,
3103 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003104 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003105 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003106
Dave Houltonf5217612018-02-02 16:18:52 -07003107 VkImageAspectFlags legal_aspect_flags =
3108 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 -07003109 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003110 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3111 }
3112
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003113 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003114 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003115 skip |= LogError(
3116 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003117 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003118 }
Dave Houltonf5217612018-02-02 16:18:52 -07003119 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003120 skip |= LogError(
3121 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003122 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003123 }
3124 }
3125 return skip;
3126}
3127
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003128bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3129 VkImageLayout srcImageLayout, VkImage dstImage,
3130 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003131 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003132 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003133
Dave Houltonf5217612018-02-02 16:18:52 -07003134 VkImageAspectFlags legal_aspect_flags =
3135 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 -07003136 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003137 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3138 }
3139
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003140 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003141 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003142 skip |= LogError(
3143 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003144 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
3145 }
Dave Houltonf5217612018-02-02 16:18:52 -07003146 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003147 skip |= LogError(
3148 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003149 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
3150 }
3151 }
3152 return skip;
3153}
3154
sfricke-samsung3999ef62020-02-09 17:05:59 -08003155bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3156 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3157 bool skip = false;
3158
3159 if (pRegions != nullptr) {
3160 for (uint32_t i = 0; i < regionCount; i++) {
3161 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003162 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3163 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003164 }
3165 }
3166 }
3167 return skip;
3168}
3169
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003170bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
3171 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003172 uint32_t regionCount,
3173 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003174 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003175
Dave Houltonf5217612018-02-02 16:18:52 -07003176 VkImageAspectFlags legal_aspect_flags =
3177 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 -07003178 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003179 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3180 }
3181
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003182 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003183 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003184 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
3185 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
3186 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003187 }
3188 }
3189 return skip;
3190}
3191
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003192bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
3193 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003194 uint32_t regionCount,
3195 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003196 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003197
Dave Houltonf5217612018-02-02 16:18:52 -07003198 VkImageAspectFlags legal_aspect_flags =
3199 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 -07003200 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003201 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3202 }
3203
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003204 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003205 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Petr Kraus3e6cd032020-04-14 20:41:16 +02003206 skip |= LogError(
3207 device, kVUID_PVError_UnrecognizedValue,
3208 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
3209 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003210 }
3211 }
3212 return skip;
3213}
3214
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003215bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003216 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3217 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003218 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003219
3220 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003221 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3222 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3223 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003224 }
3225
3226 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003227 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3228 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3229 "), must be greater than zero and less than or equal to 65536.",
3230 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003231 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003232 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3233 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3234 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003235 }
3236 return skip;
3237}
3238
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003239bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003240 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003241 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003242
3243 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003244 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3245 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3246 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003247 }
3248
3249 if (size != VK_WHOLE_SIZE) {
3250 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003251 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003252 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3253 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003254 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003255 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3256 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003257 }
3258 }
3259 return skip;
3260}
3261
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003262bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003263 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003264 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003265 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003266
3267 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003268 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3269 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3270 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3271 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003272 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3273 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3274 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003275 }
3276
3277 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3278 // queueFamilyIndexCount uint32_t values
3279 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003280 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3281 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3282 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3283 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003284 }
3285 }
3286
Dave Houlton413a6782018-05-22 13:01:54 -06003287 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003288 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003289 }
3290
3291 return skip;
3292}
3293
Jeff Bolz5c801d12019-10-09 10:38:45 -05003294bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003295 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003296
3297 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003298 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3299 if (present_regions) {
3300 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003301 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003302 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3303 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003304 skip |= LogError(device, kVUID_PVError_InvalidUsage,
3305 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3306 "extension swapchainCount is %i. These values must be equal.",
3307 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003308 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003309 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003310 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3311 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003312 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3313 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3314 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003315 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003316 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003317 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003318 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003319 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003320 }
3321 }
3322
3323 return skip;
3324}
3325
3326#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003327bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3328 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3329 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003330 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003331 bool skip = false;
3332
3333 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003334 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3335 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003336 }
3337
3338 return skip;
3339}
3340#endif // VK_USE_PLATFORM_WIN32_KHR
3341
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003342bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003343 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003344 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003345 bool skip = false;
3346
3347 if (pCreateInfo) {
3348 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003349 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3350 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003351 }
3352
3353 if (pCreateInfo->pPoolSizes) {
3354 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3355 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003356 skip |= LogError(
3357 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003358 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003359 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003360 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3361 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003362 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3363 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3364 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3365 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3366 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003367 }
Petr Krausc8655be2017-09-27 18:56:51 +02003368 }
3369 }
3370 }
3371
3372 return skip;
3373}
3374
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003375bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003376 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003377 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003378
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003379 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003380 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003381 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3382 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3383 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003384 }
3385
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003386 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003387 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003388 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3389 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3390 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003391 }
3392
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003393 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003394 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003395 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3396 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3397 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003398 }
3399
3400 return skip;
3401}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003402
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003403bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003404 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003405 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003406
3407 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003408 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3409 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003410 }
3411 return skip;
3412}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003413
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003414bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3415 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003416 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003417 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003418
3419 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003420 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003421 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003422 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3423 "vkCmdDispatch(): baseGroupX (%" PRIu32
3424 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3425 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003426 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003427 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3428 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3429 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3430 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003431 }
3432
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003433 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003434 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003435 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3436 "vkCmdDispatch(): baseGroupY (%" PRIu32
3437 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3438 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003439 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003440 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3441 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3442 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3443 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003444 }
3445
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003446 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003447 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003448 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3449 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3450 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3451 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003452 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003453 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3454 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3455 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3456 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003457 }
3458
3459 return skip;
3460}
3461
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003462bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3463 VkPipelineBindPoint pipelineBindPoint,
3464 VkPipelineLayout layout, uint32_t set,
3465 uint32_t descriptorWriteCount,
3466 const VkWriteDescriptorSet *pDescriptorWrites) const {
3467 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3468}
3469
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003470bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3471 uint32_t firstExclusiveScissor,
3472 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003473 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003474 bool skip = false;
3475
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003476 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003477 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003478 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003479 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3480 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3481 ") is not 0.",
3482 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003483 }
3484 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003485 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003486 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3487 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3488 ") is not 1.",
3489 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003490 }
3491 } else { // multiViewport enabled
3492 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003493 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003494 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3495 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3496 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3497 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003498 }
3499 }
3500
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003501 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003502 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3503 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3504 ") must be less than maxViewports (=%" PRIu32 ").",
3505 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003506 }
3507
3508 if (pExclusiveScissors) {
3509 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3510 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3511
3512 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003513 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3514 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3515 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003516 }
3517
3518 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003519 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3520 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3521 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003522 }
3523
3524 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3525 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003526 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3527 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3528 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3529 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003530 }
3531
3532 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3533 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003534 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3535 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3536 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3537 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003538 }
3539 }
3540 }
3541
3542 return skip;
3543}
3544
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003545bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3546 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003547 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003548 bool skip = false;
3549 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003550 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3551 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3552 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003553 } else {
3554 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3555 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003556 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3557 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3558 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3559 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003560 }
3561 }
3562
3563 return skip;
3564}
3565
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003566bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3567 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003568 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003569 bool skip = false;
3570
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003571 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003572 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003573 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003574 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3575 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3576 ") is not 0.",
3577 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003578 }
3579 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003580 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003581 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3582 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3583 ") is not 1.",
3584 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003585 }
3586 }
3587
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003588 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003589 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3590 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3591 ") must be less than maxViewports (=%" PRIu32 ").",
3592 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003593 }
3594
3595 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003596 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003597 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3598 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3599 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3600 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003601 }
3602
3603 return skip;
3604}
3605
Jeff Bolz5c801d12019-10-09 10:38:45 -05003606bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3607 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3608 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003609 bool skip = false;
3610
Dave Houlton142c4cb2018-10-17 15:04:41 -06003611 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003612 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3613 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3614 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003615 }
3616
3617 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003618 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003619 }
3620
3621 return skip;
3622}
3623
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003624bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003625 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003626 bool skip = false;
3627
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003628 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003629 skip |= LogError(
3630 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003631 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3632 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003633 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003634 }
3635
3636 return skip;
3637}
3638
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003639bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3640 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003641 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003642 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003643 static const int condition_multiples = 0b0011;
3644 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003645 skip |= LogError(
3646 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003647 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003648 }
Lockee1c22882019-06-10 16:02:54 -06003649 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003650 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3651 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3652 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3653 stride);
Lockee1c22882019-06-10 16:02:54 -06003654 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003655 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003656 skip |= LogError(
3657 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3658 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003659 }
3660
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003661 return skip;
3662}
3663
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003664bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3665 VkDeviceSize offset, VkBuffer countBuffer,
3666 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003667 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003668 bool skip = false;
3669
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003670 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003671 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3672 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3673 "), is not a multiple of 4.",
3674 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003675 }
3676
3677 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003678 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
3679 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3680 "), is not a multiple of 4.",
3681 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003682 }
3683
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003684 return skip;
3685}
3686
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003687bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003688 const VkAllocationCallbacks *pAllocator,
3689 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003690 bool skip = false;
3691
3692 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3693 if (pCreateInfo != nullptr) {
3694 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3695 // VkQueryPipelineStatisticFlagBits values
3696 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3697 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003698 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
3699 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3700 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3701 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003702 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07003703 if (pCreateInfo->queryCount == 0) {
3704 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
3705 "vkCreateQueryPool(): queryCount must be greater than zero.");
3706 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003707 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003708 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003709}
3710
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003711bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3712 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003713 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003714 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3715 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003716}
3717
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003718void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003719 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3720 VkResult result) {
3721 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003722 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003723}
3724
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003725void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003726 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3727 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003728 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003729 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003730 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003731}
3732
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003733void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
3734 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003735 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003736 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003737 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003738}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003739
3740bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003741 const VkAllocationCallbacks *pAllocator,
3742 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003743 bool skip = false;
3744
3745 if (pAllocateInfo) {
3746 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
3747 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003748 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
3749 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003750 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003751
3752 VkMemoryAllocateFlags flags = 0;
3753 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
3754 if (flags_info) {
3755 flags = flags_info->flags;
3756 }
3757
3758 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
3759 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
3760 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003761 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
3762 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
3763 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003764 }
3765
3766#ifdef VK_USE_PLATFORM_WIN32_KHR
3767 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
3768#endif
3769 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
3770 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
3771#ifdef VK_USE_PLATFORM_ANDROID_KHR
3772 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
3773#endif
3774
3775 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003776 skip |= LogError(
3777 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003778 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
3779 }
3780 if (
3781#ifdef VK_USE_PLATFORM_WIN32_KHR
3782 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
3783#endif
3784 (import_memory_fd && import_memory_fd->handleType) ||
3785#ifdef VK_USE_PLATFORM_ANDROID_KHR
3786 (import_memory_ahb && import_memory_ahb->buffer) ||
3787#endif
3788 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003789 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
3790 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003791 }
3792 }
3793
3794 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003795 VkBool32 capture_replay = false;
3796 VkBool32 buffer_device_address = false;
3797 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
3798 if (vulkan_12_features) {
3799 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
3800 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
3801 } else {
3802 const auto *bda_features =
3803 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
3804 if (bda_features) {
3805 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
3806 buffer_device_address = bda_features->bufferDeviceAddress;
3807 }
3808 }
3809 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003810 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
3811 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
3812 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003813 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003814 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003815 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
3816 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003817 }
3818 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003819 }
3820 return skip;
3821}
Ricardo Garciaa4935972019-02-21 17:43:18 +01003822
Jason Macnak192fa0e2019-07-26 15:07:16 -07003823bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003824 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003825 bool skip = false;
3826
3827 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
3828 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
3829 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003830 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003831 } else {
3832 uint32_t vertex_component_size = 0;
3833 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
3834 vertex_component_size = 4;
3835 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
3836 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
3837 vertex_component_size = 2;
3838 }
3839 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003840 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003841 }
3842 }
3843
3844 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
3845 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003846 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003847 } else {
3848 uint32_t index_element_size = 0;
3849 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
3850 index_element_size = 4;
3851 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
3852 index_element_size = 2;
3853 }
3854 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003855 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003856 }
3857 }
3858 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
3859 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003860 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003861 }
3862 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003863 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003864 }
3865 }
3866
3867 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003868 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003869 }
3870
3871 return skip;
3872}
3873
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003874bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
3875 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003876 bool skip = false;
3877
3878 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003879 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003880 }
3881 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003882 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003883 }
3884
3885 return skip;
3886}
3887
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003888bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
3889 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003890 bool skip = false;
3891 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003892 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003893 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003894 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003895 }
3896 return skip;
3897}
3898
3899bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003900 VkAccelerationStructureNV object_handle,
Jason Macnak192fa0e2019-07-26 15:07:16 -07003901 const char *func_name) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003902 bool skip = false;
3903 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003904 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
3905 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
3906 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003907 }
3908 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003909 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
3910 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
3911 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003912 }
3913 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
3914 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003915 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
3916 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
3917 "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 -07003918 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003919 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003920 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
3921 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
3922 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003923 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003924 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003925 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
3926 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
3927 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003928 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003929 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07003930 uint64_t total_triangle_count = 0;
3931 for (uint32_t i = 0; i < info.geometryCount; i++) {
3932 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07003933
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003934 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003935
Jason Macnak5c954952019-07-09 15:46:12 -07003936 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
3937 continue;
3938 }
3939 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
3940 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003941 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003942 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
3943 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
3944 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003945 }
3946 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003947 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
3948 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
3949 for (uint32_t i = 1; i < info.geometryCount; i++) {
3950 const VkGeometryNV &geometry = info.pGeometries[i];
3951 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003952 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003953 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
3954 "info.pGeometries[0].geometryType.",
3955 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07003956 }
3957 }
3958 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003959 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
3960 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
3961 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
3962 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
3963 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
3964 "or VK_GEOMETRY_TYPE_AABBS_NV.");
3965 }
3966 }
3967 skip |=
3968 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
3969 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-03486");
Jason Macnak5c954952019-07-09 15:46:12 -07003970 return skip;
3971}
3972
Ricardo Garciaa4935972019-02-21 17:43:18 +01003973bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
3974 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003975 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01003976 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01003977 if (pCreateInfo) {
3978 if ((pCreateInfo->compactedSize != 0) &&
3979 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003980 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
3981 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
3982 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
3983 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01003984 }
Jason Macnak5c954952019-07-09 15:46:12 -07003985
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003986 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
Jason Macnak192fa0e2019-07-26 15:07:16 -07003987 "vkCreateAccelerationStructureNV()");
Ricardo Garciaa4935972019-02-21 17:43:18 +01003988 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01003989 return skip;
3990}
Mike Schuchardt21638df2019-03-16 10:52:02 -07003991
Jeff Bolz5c801d12019-10-09 10:38:45 -05003992bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
3993 const VkAccelerationStructureInfoNV *pInfo,
3994 VkBuffer instanceData, VkDeviceSize instanceOffset,
3995 VkBool32 update, VkAccelerationStructureNV dst,
3996 VkAccelerationStructureNV src, VkBuffer scratch,
3997 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003998 bool skip = false;
3999
4000 if (pInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004001 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()");
Jason Macnak5c954952019-07-09 15:46:12 -07004002 }
4003
4004 return skip;
4005}
4006
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004007bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4008 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4009 VkAccelerationStructureKHR *pAccelerationStructure) const {
4010 bool skip = false;
4011
4012 if (pCreateInfo) {
4013 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
4014 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4015 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4016 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
4017 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
4018 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4019 i);
4020 }
4021 }
4022
4023 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4024 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4025 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
4026 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
4027 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4028 i);
4029 }
4030 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004031 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
4032 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
4033 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
4034 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
4035 skip |= LogError(
4036 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
4037 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
4038 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
4039 }
4040 }
4041 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
4042 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
4043 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
4044 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4045 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
4046 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
4047 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
4048 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
4049 }
4050 }
4051 }
4052
4053 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
4054 pCreateInfo->maxGeometryCount != 1) {
4055 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
4056 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4057 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004058 }
4059
4060 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
4061 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
4062 skip |= LogError(
4063 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
4064 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
4065 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
4066 }
4067
4068 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
4069 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
4070 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
4071 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
4072 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
4073 }
4074
4075 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
4076 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
4077 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
4078 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
4079 if (geometry_type != first_geometry_type) {
4080 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
4081 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
4082 "pGeometryInfos[0].geometryType.",
4083 i);
4084 }
4085 }
4086 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004087 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
4088 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
4089 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
4090 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
4091 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
4092 "maxGeometryCount %d.",
4093 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
4094 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004095 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004096 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4097 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
4098 if (pCreateInfo->deviceAddress != 0) {
4099 skip |=
4100 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
4101 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
4102 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
4103 }
4104 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004105 return skip;
4106}
4107
Jason Macnak5c954952019-07-09 15:46:12 -07004108bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4109 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004110 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004111 bool skip = false;
4112 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004113 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4114 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004115 }
4116 return skip;
4117}
4118
Peter Chen85366392019-05-14 15:20:11 -04004119bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4120 uint32_t createInfoCount,
4121 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4122 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004123 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004124 bool skip = false;
4125
4126 for (uint32_t i = 0; i < createInfoCount; i++) {
4127 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4128 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004129 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4130 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4131 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4132 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4133 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004134 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004135
4136 const auto *pipeline_cache_contol_features =
4137 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4138 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4139 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4140 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4141 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4142 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4143 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4144 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4145 }
4146 }
4147
sourav parmarf4a78252020-04-10 13:04:21 -07004148 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4149 skip |=
4150 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4151 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4152 }
4153 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4154 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4155 skip |=
4156 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4157 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4158 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4159 }
4160 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4161 if (pCreateInfos[i].basePipelineIndex != -1) {
4162 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4163 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4164 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4165 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4166 "and pCreateInfos->basePipelineIndex is not -1.");
4167 }
4168 }
4169 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4170 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4171 skip |=
4172 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4173 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4174 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4175 "commands pCreateInfos parameter.");
4176 }
4177 } else {
4178 if (pCreateInfos[i].basePipelineIndex != -1) {
4179 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4180 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4181 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4182 }
4183 }
4184 }
4185 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4186 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4187 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4188 }
4189 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4190 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4191 "vkCreateRayTracingPipelinesNV: flags must not include "
4192 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4193 }
4194 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4195 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4196 "vkCreateRayTracingPipelinesNV: flags must not include "
4197 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4198 }
4199 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4200 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4201 "vkCreateRayTracingPipelinesNV: flags must not include "
4202 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4203 }
4204 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4205 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4206 "vkCreateRayTracingPipelinesNV: flags must not include "
4207 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4208 }
4209 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4210 skip |= LogError(
4211 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4212 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4213 }
4214 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4215 skip |= LogError(
4216 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4217 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4218 }
Peter Chen85366392019-05-14 15:20:11 -04004219 }
4220
4221 return skip;
4222}
4223
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004224bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4225 uint32_t createInfoCount,
4226 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4227 const VkAllocationCallbacks *pAllocator,
4228 VkPipeline *pPipelines) const {
4229 bool skip = false;
4230
4231 for (uint32_t i = 0; i < createInfoCount; i++) {
4232 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4233 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4234 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4235 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4236 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4237 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4238 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4239 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004240 const auto *pipeline_cache_contol_features =
4241 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4242 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4243 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4244 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4245 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4246 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4247 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4248 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4249 }
4250 }
4251 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4252 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4253 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4254 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4255 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4256 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4257 }
4258 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4259 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4260 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4261 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4262 }
4263 }
4264
sourav parmarf4a78252020-04-10 13:04:21 -07004265 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4266 skip |=
4267 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4268 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4269 }
4270 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4271 if (pCreateInfos[i].pLibraryInterface == NULL)
4272 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4273 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4274 }
4275 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4276 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4277 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4278 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4279 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4280 skip |= LogError(
4281 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4282 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4283 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4284 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4285 "must not be VK_SHADER_UNUSED_KHR");
4286 }
4287 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4288 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4289 skip |= LogError(
4290 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4291 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4292 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4293 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4294 "element must not be VK_SHADER_UNUSED_KHR");
4295 }
4296 }
4297 }
4298 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4299 if (pCreateInfos[i].basePipelineIndex != -1) {
4300 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4301 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4302 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4303 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4304 "and pCreateInfos->basePipelineIndex is not -1.");
4305 }
4306 }
4307 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4308 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4309 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4310 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4311 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4312 "commands pCreateInfos parameter %d.",
4313 pCreateInfos[i].basePipelineIndex, createInfoCount);
4314 }
4315 } else {
4316 if (pCreateInfos[i].basePipelineIndex != -1) {
4317 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4318 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4319 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4320 }
4321 }
4322 }
4323 if (pCreateInfos[i].libraries.libraryCount == 0) {
4324 if (pCreateInfos[i].stageCount == 0) {
4325 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4326 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4327 }
4328 if (pCreateInfos[i].groupCount == 0) {
4329 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4330 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4331 }
4332 } else {
4333 if (pCreateInfos[i].pLibraryInterface == NULL) {
4334 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4335 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4336 }
4337 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004338 }
4339
4340 return skip;
4341}
4342
Mike Schuchardt21638df2019-03-16 10:52:02 -07004343#ifdef VK_USE_PLATFORM_WIN32_KHR
4344bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4345 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004346 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004347 bool skip = false;
4348 if (!device_extensions.vk_khr_swapchain)
4349 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4350 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4351 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4352 if (!device_extensions.vk_khr_surface)
4353 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4354 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4355 skip |=
4356 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4357 if (!device_extensions.vk_ext_full_screen_exclusive)
4358 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4359 skip |= validate_struct_type(
4360 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4361 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4362 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4363 if (pSurfaceInfo != NULL) {
4364 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4365 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4366 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4367
4368 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4369 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4370 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4371 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004372 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4373 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004374
4375 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4376 }
4377 return skip;
4378}
4379#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004380
4381bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4382 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004383 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004384 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4385 bool skip = false;
4386 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4387 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4388 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4389 }
4390 return skip;
4391}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004392
4393bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004394 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004395 bool skip = false;
4396
4397 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004398 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4399 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004400 }
4401
4402 return skip;
4403}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004404
4405bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004406 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004407 bool skip = false;
4408
4409 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004410 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4411 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004412 }
4413
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004414 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Piers Daniell8fd03f52019-08-21 12:07:53 -06004415 if (indexType == VK_INDEX_TYPE_UINT8_EXT && !index_type_uint8_features->indexTypeUint8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004416 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4417 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004418 }
4419
4420 return skip;
4421}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004422
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004423bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4424 uint32_t bindingCount, const VkBuffer *pBuffers,
4425 const VkDeviceSize *pOffsets) const {
4426 bool skip = false;
4427 if (firstBinding > device_limits.maxVertexInputBindings) {
4428 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4429 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4430 device_limits.maxVertexInputBindings);
4431 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4432 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4433 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4434 "maxVertexInputBindings (%u)",
4435 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4436 }
4437
4438 return skip;
4439}
4440
Mark Lobodzinski84988402019-09-11 15:27:30 -06004441bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004442 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004443 bool skip = false;
4444 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004445 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4446 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004447 }
4448 return skip;
4449}
4450
4451bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004452 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004453 bool skip = false;
4454 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004455 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4456 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004457 }
4458 return skip;
4459}
Petr Kraus3d720392019-11-13 02:52:39 +01004460
4461bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4462 VkSemaphore semaphore, VkFence fence,
4463 uint32_t *pImageIndex) const {
4464 bool skip = false;
4465
4466 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004467 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4468 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004469 }
4470
4471 return skip;
4472}
4473
4474bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4475 uint32_t *pImageIndex) const {
4476 bool skip = false;
4477
4478 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004479 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4480 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004481 }
4482
4483 return skip;
4484}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004485
4486bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
4487 uint32_t firstInstance, VkBuffer counterBuffer,
4488 VkDeviceSize counterBufferOffset,
4489 uint32_t counterOffset, uint32_t vertexStride) const {
4490 bool skip = false;
4491
4492 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004493 skip |= LogError(
4494 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004495 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
4496 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
4497 }
4498
4499 return skip;
4500}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004501
4502bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
4503 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4504 const VkAllocationCallbacks *pAllocator,
4505 VkSamplerYcbcrConversion *pYcbcrConversion,
4506 const char *apiName) const {
4507 bool skip = false;
4508
4509 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004510 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004511 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004512 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
4513 "samplerYcbcrConversion must be enabled to call %s.", apiName);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004514 }
4515 return skip;
4516}
4517
4518bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
4519 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4520 const VkAllocationCallbacks *pAllocator,
4521 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4522 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4523 "vkCreateSamplerYcbcrConversion");
4524}
4525
4526bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
4527 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4528 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4529 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4530 "vkCreateSamplerYcbcrConversionKHR");
4531}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004532
4533bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
4534 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
4535 bool skip = false;
4536 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
4537 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
4538
4539 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004540 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
4541 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
4542 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
4543 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
4544 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004545 }
4546 return skip;
4547}
sourav parmara96ab1a2020-04-25 16:28:23 -07004548
4549bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
4550 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4551 bool skip = false;
4552 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4553 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4554 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4555 }
4556 return skip;
4557}
4558
4559bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
4560 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4561 bool skip = false;
4562 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4563 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
4564 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4565 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4566 }
4567 return skip;
4568}
4569
4570bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
4571 const char *api_name) const {
4572 bool skip = false;
4573 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
4574 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
4575 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
4576 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
4577 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
4578 api_name);
4579 }
4580 return skip;
4581}
4582
4583bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
4584 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4585 bool skip = false;
4586 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
4587 return skip;
4588}
4589
4590bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
4591 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4592 bool skip = false;
4593 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
4594 return skip;
4595}
4596
4597bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
4598 const char *api_name) const {
4599 bool skip = false;
4600 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
4601 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
4602 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
4603 }
4604 return skip;
4605}
4606
4607bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
4608 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4609 bool skip = false;
4610 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()");
4611 return skip;
4612}
4613bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
4614 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4615 bool skip = false;
4616 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()");
4617 return skip;
4618}