blob: a0403e35e661b8987efa49d5f866ea05e67c4b7e [file] [log] [blame]
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08001/* Copyright (c) 2015-2020 The Khronos Group Inc.
2 * Copyright (c) 2015-2020 Valve Corporation
3 * Copyright (c) 2015-2020 LunarG, Inc.
4 * Copyright (C) 2015-2020 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Mark Lobodzinskid4950072017-08-01 13:02:20 -060028static const int MaxParamCheckerStringLength = 256;
29
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070036bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050037 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060038 bool skip = false;
39
40 VkStringErrorFlags result = vk_string_validate(MaxParamCheckerStringLength, validateString);
41
42 if (result == VK_STRING_ERROR_NONE) {
43 return skip;
44 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070045 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
46 MaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060047 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070048 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
49 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060050 }
51 return skip;
52}
53
Jeff Bolz46c0ea02019-10-09 13:06:29 -050054bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060055 bool skip = false;
56 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
57 if (api_version_nopatch != effective_api_version) {
58 if (api_version_nopatch < VK_API_VERSION_1_0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070059 skip |= LogError(instance, kVUIDUndefined,
60 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
61 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
62 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060063 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070064 skip |= LogWarning(instance, kVUIDUndefined,
65 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
66 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
67 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060068 }
69 }
70 return skip;
71}
72
Jeff Bolz46c0ea02019-10-09 13:06:29 -050073bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060074 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060075 // Create and use a local instance extension object, as an actual instance has not been created yet
76 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
77 InstanceExtensions local_instance_extensions;
78 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
79
John Zulauf620755c2018-04-16 11:00:43 -060080 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060081 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
82 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060083 }
84
85 return skip;
86}
87
John Zulauf620755c2018-04-16 11:00:43 -060088template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -070089ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
90 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -060091 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -070092 ExtEnabled state =
93 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -060094 return state;
95}
96
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070097bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -050098 const VkAllocationCallbacks *pAllocator,
99 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700100 bool skip = false;
101 // Note: From the spec--
102 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
103 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
104 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700105 ? pCreateInfo->pApplicationInfo->apiVersion
106 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700107 skip |= validate_api_version(local_api_version, api_version);
108 skip |= validate_instance_extensions(pCreateInfo);
109 return skip;
110}
111
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700112void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700113 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
114 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700115 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
116 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700117 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700118 this->instance_extensions = instance_data->instance_extensions;
119}
120
121void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700122 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700123 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700124 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700125 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
126 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700127
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700128 // Parmeter validation also uses extension data
129 stateless_validation->device_extensions = this->device_extensions;
130
131 VkPhysicalDeviceProperties device_properties = {};
132 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600133 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700134 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
135
136 if (device_extensions.vk_nv_shading_rate_image) {
137 // Get the needed shading rate image limits
138 auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
139 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600140 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700141 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
142 }
143
144 if (device_extensions.vk_nv_mesh_shader) {
145 // Get the needed mesh shader limits
146 auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>();
147 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600148 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700149 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
150 }
151
Jason Macnak5c954952019-07-09 15:46:12 -0700152 if (device_extensions.vk_nv_ray_tracing) {
153 // Get the needed ray tracing limits
154 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>();
155 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
156 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500157 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
158 }
159
160 if (device_extensions.vk_khr_ray_tracing) {
161 // Get the needed ray tracing limits
162 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesKHR>();
163 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
164 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
165 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700166 }
167
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700168 if (device_extensions.vk_ext_transform_feedback) {
169 // Get the needed transform feedback limits
170 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
171 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
172 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
173 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
174 }
175
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800176 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
177
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700178 // Save app-enabled features in this device's validation object
179 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200180 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
181 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
182 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
183 if (features2) {
184 tmp_features2_state.features = features2->features;
185 } else if (pCreateInfo->pEnabledFeatures) {
186 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700187 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200188 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700189 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200190 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700191 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200192 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700193}
194
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700195bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500196 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600197 bool skip = false;
198
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200199 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
200 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
201 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600202 }
203
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200204 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
205 skip |=
206 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
207 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
208 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
209 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600210 }
211
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200212 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700213 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
214 bool negative_viewport =
215 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200216 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700217 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
218 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
219 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200220 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600221 }
222
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600223 {
224 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
225 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
226 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700227 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
228 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
229 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600230 }
231 }
232
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600233 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
234 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600235 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
236 if (features2) {
237 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700238 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700239 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
240 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600241 }
242 }
243
Locke77fad1c2019-04-16 13:09:03 -0600244 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
245 if (features2) {
246 if (!instance_extensions.vk_khr_get_physical_device_properties_2) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700247 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
248 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, "
249 "VK_KHR_get_physical_device_properties2 must be enabled when it creates an instance.");
Locke77fad1c2019-04-16 13:09:03 -0600250 }
251 }
252
Jeff Bolz165818a2020-05-08 11:19:03 -0500253 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
254 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
255 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
256 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
257 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
258 }
259
Locke77fad1c2019-04-16 13:09:03 -0600260 auto vertex_attribute_divisor_features =
261 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
262 if (vertex_attribute_divisor_features) {
263 bool extension_found = false;
264 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
265 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
266 VK_MAX_EXTENSION_NAME_SIZE)) {
267 extension_found = true;
268 break;
269 }
270 }
271 if (!extension_found) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700272 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
273 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
274 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600275 }
276 }
277
Tony-LunarG28017bc2020-01-23 14:40:25 -0700278 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
279 if (vulkan_11_features) {
280 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
281 while (current) {
282 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
283 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
284 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
285 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
286 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
287 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700288 skip |= LogError(
289 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700290 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
291 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
292 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
293 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
294 break;
295 }
296 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
297 }
298 }
299
300 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
301 if (vulkan_12_features) {
302 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
303 while (current) {
304 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
305 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
306 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
307 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
308 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
309 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
310 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
311 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
312 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
313 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
314 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
315 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
316 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700317 skip |= LogError(
318 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700319 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
320 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
321 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
322 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
323 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
324 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
325 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
326 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
327 break;
328 }
329 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
330 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700331 // Check features are enabled if matching extension is passed in as well
332 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
333 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
334 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
335 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
336 skip |= LogError(
337 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
338 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
339 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
340 }
341 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
342 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
343 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
344 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
345 "is not VK_TRUE.",
346 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
347 }
348 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
349 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
350 skip |= LogError(
351 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
352 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
353 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
354 }
355 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
356 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
357 skip |= LogError(
358 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
359 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
360 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
361 }
362 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
363 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
364 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
365 skip |=
366 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
367 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
368 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
369 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
370 }
371 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700372 }
373
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600374 // Validate pCreateInfo->pQueueCreateInfos
375 if (pCreateInfo->pQueueCreateInfos) {
376 std::unordered_set<uint32_t> set;
377
378 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700379 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
380 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600381 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700382 skip |=
383 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
384 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
385 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
386 "index value.",
387 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600388 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700389 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
390 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
391 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
392 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600393 } else {
394 set.insert(requested_queue_family);
395 }
396
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700397 if (queue_create_info.pQueuePriorities != nullptr) {
398 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
399 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600400 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700401 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
402 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
403 "] (=%f) is not between 0 and 1 (inclusive).",
404 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600405 }
406 }
407 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700408
409 // Need to know if protectedMemory feature is passed in preCall to creating the device
410 VkBool32 protectedMemory = VK_FALSE;
411 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
412 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
413 if (protected_features) {
414 protectedMemory = protected_features->protectedMemory;
415 } else if (vulkan_11_features) {
416 protectedMemory = vulkan_11_features->protectedMemory;
417 }
418 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) {
419 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
420 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
421 "protectedMemory feature being set as well.");
422 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600423 }
424 }
425
426 return skip;
427}
428
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500429bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700430 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700431 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
432 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
433 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600434 }
435
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700436 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600437}
438
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700439bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500440 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100441 bool skip = false;
442
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600443 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700444 skip |=
445 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600446
447 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
448 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
449 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
450 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700451 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
452 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
453 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600454 }
455
456 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
457 // queueFamilyIndexCount uint32_t values
458 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700459 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
460 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
461 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
462 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600463 }
464 }
465
466 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
467 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
468 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
469 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700470 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
471 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
472 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600473 }
474 }
475
476 return skip;
477}
478
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700479bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500480 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600481 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600482
483 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600484 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
485 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
486 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
487 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700488 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
489 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
490 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600491 }
492
493 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
494 // queueFamilyIndexCount uint32_t values
495 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700496 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
497 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
498 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
499 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600500 }
501 }
502
Dave Houlton413a6782018-05-22 13:01:54 -0600503 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700504 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600505 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700506 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600507 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700508 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600509
Dave Houlton413a6782018-05-22 13:01:54 -0600510 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700511 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600512 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700513 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600514
Dave Houlton130c0212018-01-29 13:39:56 -0700515 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700516 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
517 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700518 skip |= LogError(
519 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600520 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
521 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700522 }
523
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600524 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100525 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
526 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700527 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
528 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
529 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600530 }
531
532 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100533 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
534 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700535 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
536 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
537 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
538 ") are not equal.",
539 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100540 }
541
542 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700543 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
544 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
545 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
546 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100547 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600548 }
549
550 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700551 skip |= LogError(
552 device, "VUID-VkImageCreateInfo-imageType-00957",
553 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600554 }
555 }
556
Dave Houlton130c0212018-01-29 13:39:56 -0700557 // 3D image may have only 1 layer
558 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700559 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
560 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700561 }
562
563 // If multi-sample, validate type, usage, tiling and mip levels.
564 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
565 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600566 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700567 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
568 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700569 }
570
571 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
572 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
573 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
574 // At least one of the legal attachment bits must be set
575 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700576 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
577 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700578 }
579 // No flags other than the legal attachment bits may be set
580 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
581 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700582 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
583 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700584 }
585 }
586
Jeff Bolzef40fec2018-09-01 22:04:34 -0500587 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600588 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500589 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600590 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
591 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500592 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600593 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700594 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
595 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
596 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600597 }
598
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600599 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700600 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
601 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
602 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600603 }
604
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700605 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700606 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
607 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
608 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100609 }
610
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600611 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
612 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
613 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
614 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700615 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
616 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
617 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600618 }
619
620 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
621 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
622 // Linear tiling is unsupported
623 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700624 skip |= LogError(device, kVUID_PVError_InvalidUsage,
625 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
626 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600627 }
628
629 // Sparse 1D image isn't valid
630 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700631 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
632 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600633 }
634
635 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700636 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700637 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
638 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
639 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600640 }
641
642 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700643 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700644 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
645 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
646 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600647 }
648
649 // Multi-sample 2D image when device doesn't support it
650 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700651 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600652 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700653 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
654 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
655 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700656 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600657 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700658 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
659 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
660 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700661 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600662 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700663 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
664 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
665 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700666 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600667 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700668 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
669 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
670 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600671 }
672 }
673 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500674
Jeff Bolz9af91c52018-09-01 21:53:57 -0500675 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
676 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700677 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
678 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
679 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500680 }
681 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700682 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
683 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
684 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500685 }
686 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700687 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
688 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
689 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500690 }
691 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500692
693 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600694 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700695 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
696 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
697 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500698 }
699
Dave Houlton142c4cb2018-10-17 15:04:41 -0600700 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700701 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
702 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
703 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
704 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500705 }
706
Dave Houlton142c4cb2018-10-17 15:04:41 -0600707 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700708 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
709 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
710 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
711 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500712 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600713 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700714 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
715 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
716 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
717 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500718 }
719 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500720
sfricke-samsung8f658d42020-05-03 20:12:24 -0700721 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
722 (FormatHasDepth(pCreateInfo->format) == false)) {
723 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
724 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
725 "format must be a depth or depth/stencil format.");
726 }
727
Andrew Fobel3abeb992020-01-20 16:33:22 -0500728 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
729 if (image_stencil_struct != nullptr) {
730 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
731 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
732 // No flags other than the legal attachment bits may be set
733 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
734 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700735 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
736 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
737 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
738 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500739 }
740 }
741
742 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
743 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
744 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
745 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700746 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
747 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
748 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
749 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500750 }
751
752 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
753 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700754 LogError(device, "VUID-VkImageCreateInfo-format-02537",
755 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
756 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
757 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500758 }
759 }
760
761 if (!physical_device_features.shaderStorageImageMultisample &&
762 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
763 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
764 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700765 LogError(device, "VUID-VkImageCreateInfo-format-02538",
766 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
767 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
768 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500769 }
770
771 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
772 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700773 skip |= LogError(
774 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500775 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
776 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
777 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
778 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
779 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700780 skip |= LogError(
781 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500782 "vkCreateImage(): Depth-stencil image in which usage does not include "
783 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
784 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
785 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
786 }
787
788 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
789 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700790 skip |= LogError(
791 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500792 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
793 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
794 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
795 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
796 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700797 skip |= LogError(
798 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500799 "vkCreateImage(): Depth-stencil image in which usage does not include "
800 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
801 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
802 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
803 }
804 }
805 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700806
807 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
808 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
809 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
810 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
811 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
812 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700813
814 if (device_extensions.vk_ext_image_drm_format_modifier) {
815 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
816 const auto drm_format_mod_explict =
817 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
818 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
819 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
820 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
821 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
822 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
823 "either VkImageDrmFormatModifierListCreateInfoEXT or "
824 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
825 }
826 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
827 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
828 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
829 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
830 "in the pNext chain");
831 }
832 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600833 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500834
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600835 return skip;
836}
837
Jeff Bolz99e3f632020-03-24 22:59:22 -0500838bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
839 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
840 bool skip = false;
841
842 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700843 // Validate feature set if using CUBE_ARRAY
844 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
845 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
846 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
847 "enabling the imageCubeArray feature.");
848 }
849
Jeff Bolz99e3f632020-03-24 22:59:22 -0500850 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
851 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
852 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -0700853 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -0500854 pCreateInfo->subresourceRange.layerCount);
855 }
856 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700857 skip |= LogError(
858 device, "VUID-VkImageViewCreateInfo-viewType-02961",
859 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
860 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -0500861 }
862 }
863 }
864 return skip;
865}
866
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600867bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700868 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100869 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100870
871 // Note: for numerical correctness
872 // - float comparisons should expect NaN (comparison always false).
873 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
874
875 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -0700876 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100877 if (v1_f <= 0.0f) return true;
878
879 float intpart;
880 const float fract = modff(v1_f, &intpart);
881
882 assert(std::numeric_limits<float>::radix == 2);
883 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
884 if (intpart >= u32_max_plus1) return false;
885
886 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
887 if (v1_u32 < v2_u32)
888 return true;
889 else if (v1_u32 == v2_u32 && fract == 0.0f)
890 return true;
891 else
892 return false;
893 };
894
895 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
896 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
897 return (v1_f <= v2_f);
898 };
899
900 // width
901 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700902 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100903
904 if (!(viewport.width > 0.0f)) {
905 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700906 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
907 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100908 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
909 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700910 skip |= LogError(object, "VUID-VkViewport-width-01771",
911 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
912 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100913 } else if (!f_lte_u32_exact(viewport.width, max_w) && f_lte_u32_direct(viewport.width, max_w)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700914 skip |= LogWarning(object, kVUID_PVError_NONE,
915 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
916 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
917 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100918 }
919
920 // height
921 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -0700922 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700923 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100924
925 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
926 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700927 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
928 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100929 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
930 height_healthy = false;
931
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700932 skip |= LogError(object, "VUID-VkViewport-height-01773",
933 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
934 ").",
935 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100936 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
937 height_healthy = false;
938
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700939 skip |= LogWarning(
940 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +0100941 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600942 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600943 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100944 }
945
946 // x
947 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700948 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100949 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700950 skip |= LogError(object, "VUID-VkViewport-x-01774",
951 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
952 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100953 }
954
955 // x + width
956 if (x_healthy && width_healthy) {
957 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700958 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700959 skip |= LogError(
960 object, "VUID-VkViewport-x-01232",
961 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
962 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
963 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100964 }
965 }
966
967 // y
968 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700969 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100970 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700971 skip |= LogError(object, "VUID-VkViewport-y-01775",
972 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
973 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700974 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100975 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700976 skip |= LogError(object, "VUID-VkViewport-y-01776",
977 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
978 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100979 }
980
981 // y + height
982 if (y_healthy && height_healthy) {
983 const float boundary = viewport.y + viewport.height;
984
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700985 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700986 skip |= LogError(object, "VUID-VkViewport-y-01233",
987 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
988 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
989 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700990 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600991 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700992 LogError(object, "VUID-VkViewport-y-01777",
993 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
994 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
995 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100996 }
997 }
998
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700999 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001000 // minDepth
1001 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001002 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001003
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001004 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1005 "[0.0, 1.0] range.",
1006 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001007 }
1008
1009 // maxDepth
1010 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001011 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001012
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001013 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1014 "[0.0, 1.0] range.",
1015 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001016 }
1017 }
1018
1019 return skip;
1020}
1021
Dave Houlton142c4cb2018-10-17 15:04:41 -06001022struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001023 VkShadingRatePaletteEntryNV shadingRate;
1024 uint32_t width;
1025 uint32_t height;
1026};
1027
1028// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -06001029static SampleOrderInfo sampleOrderInfos[] = {
1030 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1031 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1032 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1033 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1034 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1035 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001036};
1037
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001038bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001039 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001040
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001041 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001042 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001043 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001044 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001045 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001046 break;
1047 }
1048 }
1049
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001050 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001051 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1052 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1053 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001054 return skip;
1055 }
1056
Dave Houlton142c4cb2018-10-17 15:04:41 -06001057 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001058 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001059 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1060 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1061 ") must "
1062 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1063 "is set in framebufferNoAttachmentsSampleCounts.",
1064 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001065 }
1066
Jeff Bolz9af91c52018-09-01 21:53:57 -05001067 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001068 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1069 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1070 ") must "
1071 "be equal to the product of sampleCount (=%" PRIu32
1072 "), the fragment width for shadingRate "
1073 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1074 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001075 }
1076
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001077 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001078 skip |= LogError(
1079 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001080 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1081 ") must "
1082 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001083 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001084 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001085
1086 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001087 // the first width*height*sampleCount bits to all be set. Note: There is no
1088 // guarantee that 64 bits is enough, but practically it's unlikely for an
1089 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001090 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001091 uint64_t sampleLocationsMask = 0;
1092 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1093 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1094 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001095 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1096 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001097 }
1098 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001099 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1100 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001101 }
1102 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001103 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1104 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001105 }
1106 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1107 sampleLocationsMask |= 1ULL << idx;
1108 }
1109
1110 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1111 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001112 skip |= LogError(
1113 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001114 "The array pSampleLocations must contain exactly one entry for "
1115 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001116 }
1117
1118 return skip;
1119}
1120
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001121bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1122 uint32_t createInfoCount,
1123 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1124 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001125 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001126 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001127
1128 if (pCreateInfos != nullptr) {
1129 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001130 bool has_dynamic_viewport = false;
1131 bool has_dynamic_scissor = false;
1132 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001133 bool has_dynamic_depth_bias = false;
1134 bool has_dynamic_blend_constant = false;
1135 bool has_dynamic_depth_bounds = false;
1136 bool has_dynamic_stencil_compare = false;
1137 bool has_dynamic_stencil_write = false;
1138 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001139 bool has_dynamic_viewport_w_scaling_nv = false;
1140 bool has_dynamic_discard_rectangle_ext = false;
1141 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001142 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001143 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001144 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001145 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001146 if (pCreateInfos[i].pDynamicState != nullptr) {
1147 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1148 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1149 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001150 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1151 if (has_dynamic_viewport == true) {
1152 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1153 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1154 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1155 i);
1156 }
1157 has_dynamic_viewport = true;
1158 }
1159 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1160 if (has_dynamic_scissor == true) {
1161 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1162 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1163 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1164 i);
1165 }
1166 has_dynamic_scissor = true;
1167 }
1168 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1169 if (has_dynamic_line_width == true) {
1170 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1171 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1172 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1173 i);
1174 }
1175 has_dynamic_line_width = true;
1176 }
1177 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1178 if (has_dynamic_depth_bias == true) {
1179 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1180 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1181 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1182 i);
1183 }
1184 has_dynamic_depth_bias = true;
1185 }
1186 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1187 if (has_dynamic_blend_constant == true) {
1188 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1189 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1190 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1191 i);
1192 }
1193 has_dynamic_blend_constant = true;
1194 }
1195 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1196 if (has_dynamic_depth_bounds == true) {
1197 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1198 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1199 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1200 i);
1201 }
1202 has_dynamic_depth_bounds = true;
1203 }
1204 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1205 if (has_dynamic_stencil_compare == true) {
1206 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1207 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1208 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1209 i);
1210 }
1211 has_dynamic_stencil_compare = true;
1212 }
1213 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1214 if (has_dynamic_stencil_write == true) {
1215 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1216 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1217 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1218 i);
1219 }
1220 has_dynamic_stencil_write = true;
1221 }
1222 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1223 if (has_dynamic_stencil_reference == true) {
1224 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1225 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1226 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1227 i);
1228 }
1229 has_dynamic_stencil_reference = true;
1230 }
1231 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1232 if (has_dynamic_viewport_w_scaling_nv == true) {
1233 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1234 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1235 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1236 i);
1237 }
1238 has_dynamic_viewport_w_scaling_nv = true;
1239 }
1240 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1241 if (has_dynamic_discard_rectangle_ext == true) {
1242 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1243 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1244 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1245 i);
1246 }
1247 has_dynamic_discard_rectangle_ext = true;
1248 }
1249 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1250 if (has_dynamic_sample_locations_ext == true) {
1251 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1252 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1253 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1254 i);
1255 }
1256 has_dynamic_sample_locations_ext = true;
1257 }
1258 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1259 if (has_dynamic_exclusive_scissor_nv == true) {
1260 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1261 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1262 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1263 i);
1264 }
1265 has_dynamic_exclusive_scissor_nv = true;
1266 }
1267 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1268 if (has_dynamic_shading_rate_palette_nv == true) {
1269 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1270 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1271 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1272 i);
1273 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001274 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001275 }
1276 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1277 if (has_dynamic_viewport_course_sample_order_nv == true) {
1278 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1279 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1280 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1281 i);
1282 }
1283 has_dynamic_viewport_course_sample_order_nv = true;
1284 }
1285 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1286 if (has_dynamic_line_stipple == true) {
1287 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1288 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1289 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1290 i);
1291 }
1292 has_dynamic_line_stipple = true;
1293 }
Petr Kraus299ba622017-11-24 03:09:03 +01001294 }
1295 }
1296
Peter Chen85366392019-05-14 15:20:11 -04001297 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1298 if ((feedback_struct != nullptr) &&
1299 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001300 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1301 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1302 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1303 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1304 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001305 }
1306
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001307 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001308
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001309 // Collect active stages and other information
1310 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001311 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001312 bool has_eval = false;
1313 bool has_control = false;
1314 if (pCreateInfos[i].pStages != nullptr) {
1315 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1316 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1317
1318 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1319 has_control = true;
1320 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1321 has_eval = true;
1322 }
1323
1324 skip |= validate_string(
1325 "vkCreateGraphicsPipelines",
1326 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1327 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1328 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001329 }
1330
1331 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1332 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1333 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1334 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1335 pCreateInfos[i].pTessellationState,
1336 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1337 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1338
1339 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1340 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1341
1342 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1343 "VkPipelineTessellationDomainOriginStateCreateInfo",
1344 pCreateInfos[i].pTessellationState->pNext,
1345 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1346 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001347 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1348 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001349
1350 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1351 pCreateInfos[i].pTessellationState->flags,
1352 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1353 }
1354
1355 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1356 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1357 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1358 pCreateInfos[i].pInputAssemblyState,
1359 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1360 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1361
1362 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1363 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001364 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001365
1366 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1367 pCreateInfos[i].pInputAssemblyState->flags,
1368 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1369
1370 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1371 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1372 pCreateInfos[i].pInputAssemblyState->topology,
1373 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1374
1375 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1376 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1377 }
1378
1379 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001380 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001381
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001382 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001383 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1384 "vkCreateGraphicsPipelines: pararameter "
1385 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1386 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001387 }
1388
1389 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1390 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1391 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1392 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1393 pCreateInfos[i].pVertexInputState->pNext, 1,
1394 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001395 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1396 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001397 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1398 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001399 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001400 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1401 skip |=
1402 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1403 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1404 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1405 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1406 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1407
1408 skip |= validate_array(
1409 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1410 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1411 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1412 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1413
1414 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1415 for (uint32_t vertexBindingDescriptionIndex = 0;
1416 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1417 ++vertexBindingDescriptionIndex) {
1418 skip |= validate_ranged_enum(
1419 "vkCreateGraphicsPipelines",
1420 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1421 AllVkVertexInputRateEnums,
1422 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1423 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1424 }
1425 }
1426
1427 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1428 for (uint32_t vertexAttributeDescriptionIndex = 0;
1429 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1430 ++vertexAttributeDescriptionIndex) {
1431 skip |= validate_ranged_enum(
1432 "vkCreateGraphicsPipelines",
1433 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1434 AllVkFormatEnums,
1435 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1436 "VUID-VkVertexInputAttributeDescription-format-parameter");
1437 }
1438 }
1439
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001440 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001441 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1442 "vkCreateGraphicsPipelines: pararameter "
1443 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1444 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1445 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001446 }
1447
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001448 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001449 skip |=
1450 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1451 "vkCreateGraphicsPipelines: pararameter "
1452 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1453 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1454 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001455 }
1456
1457 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001458 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1459 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001460 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1461 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001462 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1463 "vkCreateGraphicsPipelines: parameter "
1464 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1465 "(%" PRIu32 ") is not distinct.",
1466 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001467 }
1468 vertex_bindings.insert(vertex_bind_desc.binding);
1469
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001470 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001471 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1472 "vkCreateGraphicsPipelines: parameter "
1473 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1474 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1475 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001476 }
1477
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001478 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001479 skip |=
1480 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1481 "vkCreateGraphicsPipelines: parameter "
1482 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1483 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1484 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001485 }
1486 }
1487
Peter Kohautc7d9d392018-07-15 00:34:07 +02001488 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001489 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1490 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001491 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1492 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001493 skip |= LogError(
1494 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001495 "vkCreateGraphicsPipelines: parameter "
1496 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1497 i, d, vertex_attrib_desc.location);
1498 }
1499 attribute_locations.insert(vertex_attrib_desc.location);
1500
1501 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1502 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001503 skip |= LogError(
1504 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001505 "vkCreateGraphicsPipelines: parameter "
1506 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1507 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1508 i, d, vertex_attrib_desc.binding, i);
1509 }
1510
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001511 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001512 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1513 "vkCreateGraphicsPipelines: parameter "
1514 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1515 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1516 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001517 }
1518
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001519 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001520 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1521 "vkCreateGraphicsPipelines: parameter "
1522 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1523 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1524 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001525 }
1526
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001527 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001528 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1529 "vkCreateGraphicsPipelines: parameter "
1530 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1531 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1532 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001533 }
1534 }
1535 }
1536
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001537 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1538 if (has_control && has_eval) {
1539 if (pCreateInfos[i].pTessellationState == nullptr) {
1540 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1541 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1542 "shader stage and a tessellation evaluation shader stage, "
1543 "pCreateInfos[%d].pTessellationState must not be NULL.",
1544 i, i);
1545 } else {
1546 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1547 skip |= validate_struct_pnext(
1548 "vkCreateGraphicsPipelines",
1549 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1550 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1551 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1552 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001553
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001554 skip |= validate_reserved_flags(
1555 "vkCreateGraphicsPipelines",
1556 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1557 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001558
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001559 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1560 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1561 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1562 "vkCreateGraphicsPipelines: invalid parameter "
1563 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1564 "should be >0 and <=%u.",
1565 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1566 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001567 }
1568 }
1569 }
1570
1571 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1572 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1573 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1574 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001575 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1576 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1577 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1578 "].pViewportState (=NULL) is not a valid pointer.",
1579 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001580 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001581 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1582
1583 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001584 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1585 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1586 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1587 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001588 }
1589
Petr Krausa6103552017-11-16 21:21:58 +01001590 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1591 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001592 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1593 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001594 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1595 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001596 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001597 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001598 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001599 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001600 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001601 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1602 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001603 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001604 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1605 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001606
1607 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001608 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001609 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001610 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001611
Dave Houlton142c4cb2018-10-17 15:04:41 -06001612 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1613 pCreateInfos[i].pViewportState->pNext);
1614 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1615 pCreateInfos[i].pViewportState->pNext);
1616 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1617 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001618 const auto vp_swizzle_struct =
1619 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001620 const auto vp_w_scaling_struct =
1621 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001622
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001623 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001624 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001625 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1626 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1627 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1628 ") is not 1.",
1629 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001630 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001631
Petr Krausa6103552017-11-16 21:21:58 +01001632 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001633 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1634 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1635 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1636 ") is not 1.",
1637 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001638 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001639
Dave Houlton142c4cb2018-10-17 15:04:41 -06001640 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1641 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001642 skip |= LogError(
1643 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1644 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1645 "disabled, but pCreateInfos[%" PRIu32
1646 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1647 ") is not 1.",
1648 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001649 }
1650
Jeff Bolz9af91c52018-09-01 21:53:57 -05001651 if (shading_rate_image_struct &&
1652 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001653 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
1654 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1655 "disabled, but pCreateInfos[%" PRIu32
1656 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
1657 ") is neither 0 nor 1.",
1658 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001659 }
1660
Petr Krausa6103552017-11-16 21:21:58 +01001661 } else { // multiViewport enabled
1662 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001663 skip |= LogError(
1664 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001665 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001666 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001667 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
1668 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1669 "].pViewportState->viewportCount (=%" PRIu32
1670 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1671 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001672 }
Petr Krausa6103552017-11-16 21:21:58 +01001673
1674 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001675 skip |= LogError(
1676 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001677 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001678 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001679 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
1680 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1681 "].pViewportState->scissorCount (=%" PRIu32
1682 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1683 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001684 }
1685 }
1686
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001687 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001688 skip |=
1689 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1690 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1691 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1692 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001693 }
1694
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001695 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001696 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1697 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1698 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1699 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1700 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001701 }
1702
Petr Krausa6103552017-11-16 21:21:58 +01001703 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001704 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
1705 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1706 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1707 "].pViewportState->viewportCount (=%" PRIu32 ").",
1708 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001709 }
1710
Dave Houlton142c4cb2018-10-17 15:04:41 -06001711 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001712 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001713 skip |=
1714 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1715 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1716 ") must be zero or identical to pCreateInfos[%" PRIu32
1717 "].pViewportState->viewportCount (=%" PRIu32 ").",
1718 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001719 }
1720
Dave Houlton142c4cb2018-10-17 15:04:41 -06001721 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001722 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001723 skip |= LogError(
1724 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001725 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1726 "] "
1727 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1728 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1729 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001730 }
1731
Petr Krausa6103552017-11-16 21:21:58 +01001732 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001733 skip |= LogError(
1734 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001735 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1736 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001737 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1738 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001739 }
1740
1741 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001742 skip |= LogError(
1743 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001744 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1745 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001746 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1747 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001748 }
1749
Jeff Bolz3e71f782018-08-29 23:15:45 -05001750 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001751 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1752 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1753 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001754 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-pDynamicStates-02030",
1755 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1756 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1757 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1758 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001759 }
1760
Jeff Bolz9af91c52018-09-01 21:53:57 -05001761 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001762 shading_rate_image_struct->viewportCount > 0 &&
1763 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001764 skip |= LogError(
1765 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-pDynamicStates-02057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001766 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001767 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1768 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001769 i, i);
1770 }
1771
Chris Mayer328d8212018-12-11 14:16:18 +01001772 if (vp_swizzle_struct) {
1773 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001774 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
1775 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
1776 " does "
1777 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
1778 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01001779 }
1780 }
1781
Petr Krausb3fcdb42018-01-09 22:09:09 +01001782 // validate the VkViewports
1783 if (!has_dynamic_viewport && viewport_state.pViewports) {
1784 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
1785 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001786 const char *fn_name = "vkCreateGraphicsPipelines";
1787 skip |= manual_PreCallValidateViewport(viewport, fn_name,
1788 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
1789 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001790 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01001791 }
1792 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001793
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001794 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001795 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1796 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1797 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
1798 "VK_NV_clip_space_w_scaling extension is not enabled.",
1799 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001800 }
1801
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001802 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001803 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1804 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1805 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
1806 "VK_EXT_discard_rectangles extension is not enabled.",
1807 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001808 }
1809
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001810 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001811 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1812 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1813 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
1814 "VK_EXT_sample_locations extension is not enabled.",
1815 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001816 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001817
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001818 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001819 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1820 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1821 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
1822 "VK_NV_scissor_exclusive extension is not enabled.",
1823 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001824 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001825
1826 if (coarse_sample_order_struct &&
1827 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
1828 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001829 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
1830 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1831 "] "
1832 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
1833 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
1834 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001835 }
1836
1837 if (coarse_sample_order_struct) {
1838 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001839 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001840 }
1841 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001842
1843 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
1844 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001845 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
1846 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1847 "] "
1848 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
1849 ") "
1850 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
1851 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001852 }
1853 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001854 skip |= LogError(
1855 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001856 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1857 "] "
1858 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
1859 i);
1860 }
1861 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001862 }
1863
1864 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001865 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
1866 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
1867 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
1868 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001869 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07001870 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
1871 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
1872 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07001873 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07001874 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07001875 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001876 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001877 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07001878 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001879 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08001880 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
1881 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001882
1883 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001884 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001885 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001886 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001887
1888 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001889 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001890 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
1891 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
1892
1893 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001894 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001895 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1896 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00001897 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06001898 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001899
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001900 skip |= validate_flags(
1901 "vkCreateGraphicsPipelines",
1902 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1903 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02001904 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001905
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001906 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001907 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001908 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
1909 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
1910
1911 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001912 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001913 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
1914 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
1915
1916 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001917 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
1918 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
1919 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
1920 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001921 }
John Zulauf7acac592017-11-06 11:15:53 -07001922 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001923 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001924 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
1925 "vkCreateGraphicsPipelines(): parameter "
1926 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
1927 i);
John Zulauf7acac592017-11-06 11:15:53 -07001928 }
1929 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
1930 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
1931 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001932 skip |= LogError(
1933 device,
1934
Dave Houlton413a6782018-05-22 13:01:54 -06001935 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001936 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07001937 }
1938 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001939
1940 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
1941 pCreateInfos[i].pRasterizationState->pNext);
1942
1943 if (line_state) {
1944 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
1945 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
1946 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
1947 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001948 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1949 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1950 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
1951 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001952 }
1953 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
1954 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001955 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1956 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1957 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
1958 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001959 }
1960 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
1961 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001962 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1963 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1964 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
1965 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001966 }
1967 }
1968 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
1969 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
1970 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001971 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
1972 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
1973 "range [1,256].",
1974 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001975 }
1976 }
1977 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07001978 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001979 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1980 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001981 skip |=
1982 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
1983 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1984 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
1985 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001986 }
1987 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1988 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001989 skip |=
1990 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
1991 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1992 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
1993 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001994 }
1995 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1996 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001997 skip |=
1998 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
1999 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2000 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2001 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002002 }
2003 if (line_state->stippledLineEnable) {
2004 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2005 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002006 skip |=
2007 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2008 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2009 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2010 "stippledRectangularLines feature.",
2011 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002012 }
2013 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2014 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002015 skip |=
2016 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2017 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2018 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2019 "stippledBresenhamLines feature.",
2020 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002021 }
2022 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2023 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002024 skip |=
2025 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2026 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2027 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2028 "stippledSmoothLines feature.",
2029 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002030 }
2031 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2032 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002033 skip |=
2034 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2035 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2036 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2037 "stippledRectangularLines and strictLines features.",
2038 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002039 }
2040 }
2041 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002042 }
2043
Petr Krause91f7a12017-12-14 20:57:36 +01002044 bool uses_color_attachment = false;
2045 bool uses_depthstencil_attachment = false;
2046 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002047 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002048 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2049 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002050 const auto &subpasses_uses = subpasses_uses_it->second;
2051 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
2052 uses_color_attachment = true;
2053 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
2054 uses_depthstencil_attachment = true;
2055 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002056 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002057 }
2058
2059 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002060 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002061 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002062 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002063 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002064 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002065
2066 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002067 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002068 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002069 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002070
2071 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002072 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002073 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2074 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2075
2076 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002077 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002078 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2079 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2080
2081 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002082 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002083 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2084 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002085 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002086
2087 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002088 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002089 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2090 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2091
2092 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002093 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002094 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2095 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2096
2097 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002098 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002099 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2100 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002101 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002102
2103 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002104 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002105 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2106 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002107 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002108
2109 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002110 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002111 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2112 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002113 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002114
2115 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002116 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002117 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2118 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002119 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002120
2121 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002122 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002123 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2124 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002125 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002126
2127 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002128 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002129 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2130 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002131 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002132
2133 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002134 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002135 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2136 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002137 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002138
2139 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002140 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002141 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2142 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002143 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002144
2145 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002146 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2147 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2148 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2149 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002150 }
2151 }
2152
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002153 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2154 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2155
Petr Krause91f7a12017-12-14 20:57:36 +01002156 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002157 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2158 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2159 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2160 pCreateInfos[i].pColorBlendState,
2161 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2162 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2163
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002164 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002165 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002166 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2167 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2168 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002169 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002170 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2171 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002172
2173 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002174 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002175 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002176 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002177
2178 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002179 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002180 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2181 pCreateInfos[i].pColorBlendState->logicOpEnable);
2182
2183 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002184 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002185 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2186 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002187 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002188 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002189
2190 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2191 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2192 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002193 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002194 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2195 ParameterName::IndexVector{i, attachmentIndex}),
2196 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2197
2198 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002199 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002200 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2201 ParameterName::IndexVector{i, attachmentIndex}),
2202 "VkBlendFactor", AllVkBlendFactorEnums,
2203 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002204 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002205
2206 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002207 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002208 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2209 ParameterName::IndexVector{i, attachmentIndex}),
2210 "VkBlendFactor", AllVkBlendFactorEnums,
2211 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002212 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002213
2214 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002215 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002216 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2217 ParameterName::IndexVector{i, attachmentIndex}),
2218 "VkBlendOp", AllVkBlendOpEnums,
2219 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002220 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002221
2222 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002223 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002224 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2225 ParameterName::IndexVector{i, attachmentIndex}),
2226 "VkBlendFactor", AllVkBlendFactorEnums,
2227 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002228 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002229
2230 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002231 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002232 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2233 ParameterName::IndexVector{i, attachmentIndex}),
2234 "VkBlendFactor", AllVkBlendFactorEnums,
2235 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002236 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002237
2238 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002239 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002240 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2241 ParameterName::IndexVector{i, attachmentIndex}),
2242 "VkBlendOp", AllVkBlendOpEnums,
2243 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002244 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002245
2246 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002247 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002248 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2249 ParameterName::IndexVector{i, attachmentIndex}),
2250 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2251 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002252 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002253 }
2254 }
2255
2256 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002257 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2258 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2259 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2260 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002261 }
2262
2263 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2264 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2265 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002266 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002267 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002268 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2269 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002270 }
2271 }
2272 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002273
Petr Kraus9752aae2017-11-24 03:05:50 +01002274 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2275 if (pCreateInfos[i].basePipelineIndex != -1) {
2276 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002277 skip |=
2278 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
2279 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineHandle, must be "
2280 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
2281 "and pCreateInfos->basePipelineIndex is not -1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002282 }
2283 }
2284
Petr Kraus9752aae2017-11-24 03:05:50 +01002285 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2286 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002287 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
2288 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineIndex, must be -1 if "
2289 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
2290 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002291 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002292 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002293 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002294 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2295 "vkCreateGraphicsPipelines parameter pCreateInfos->basePipelineIndex (%d) must be a valid"
2296 "index into the pCreateInfos array, of size %d.",
2297 pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002298 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002299 }
2300 }
2301
Petr Kraus9752aae2017-11-24 03:05:50 +01002302 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002303 if (!device_extensions.vk_nv_fill_rectangle) {
2304 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2305 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002306 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2307 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2308 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2309 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002310 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2311 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002312 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2313 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2314 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2315 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002316 }
2317 } else {
2318 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2319 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2320 (physical_device_features.fillModeNonSolid == false)) {
2321 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002322 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2323 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2324 "pCreateInfos->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2325 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002326 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002327 }
Petr Kraus299ba622017-11-24 03:09:03 +01002328
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002329 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002330 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002331 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2332 "The line width state is static (pCreateInfos[%" PRIu32
2333 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2334 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2335 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2336 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002337 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002338 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002339 }
2340 }
2341
2342 return skip;
2343}
2344
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002345bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2346 uint32_t createInfoCount,
2347 const VkComputePipelineCreateInfo *pCreateInfos,
2348 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002349 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002350 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002351 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002352 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002353 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002354 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002355 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2356 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002357 skip |=
2358 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2359 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2360 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2361 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002362 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002363
2364 // Make sure compute stage is selected
2365 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002366 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2367 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2368 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002369 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002370 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002371 return skip;
2372}
2373
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002374bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002375 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002376 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002377
2378 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002379 const auto &features = physical_device_features;
2380 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002381
John Zulauf71968502017-10-26 13:51:15 -06002382 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2383 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002384 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2385 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2386 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2387 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002388 }
2389
2390 // Anistropy cannot be enabled in sampler unless enabled as a feature
2391 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002392 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2393 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2394 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002395 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002396 }
John Zulauf71968502017-10-26 13:51:15 -06002397
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002398 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2399 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002400 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2401 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2402 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2403 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002404 }
2405 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002406 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2407 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2408 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2409 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002410 }
2411 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002412 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2413 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2414 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2415 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002416 }
2417 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2418 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2419 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2420 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002421 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2422 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2423 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2424 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2425 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2426 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002427 }
2428 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002429 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2430 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2431 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002432 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002433 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002434 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2435 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2436 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002437 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002438 }
2439
2440 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2441 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002442 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2443 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07002444 const auto *sampler_reduction = lvl_find_in_chain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
2445 if (sampler_reduction != nullptr) {
2446 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
2447 skip |= LogError(
2448 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
2449 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
2450 }
2451 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002452 }
2453
2454 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2455 // valid VkBorderColor value
2456 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2457 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2458 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002459 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2460 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002461 }
2462
2463 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2464 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002465 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002466 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2467 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2468 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002469 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002470 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2471 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2472 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002473 }
John Zulauf275805c2017-10-26 15:34:49 -06002474
2475 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002476 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002477 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2478 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002479 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2480 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2481 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002482 }
2483 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002484
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002485 // Check for valid Lod range
2486 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002487 skip |=
2488 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2489 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002490 }
2491
2492 // Check mipLodBias to device limit
2493 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002494 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2495 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2496 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002497 }
2498
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002499 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2500 if (sampler_conversion != nullptr) {
2501 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2502 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2503 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2504 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002505 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002506 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002507 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2508 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2509 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2510 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2511 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2512 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2513 }
2514 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002515 }
2516
2517 return skip;
2518}
2519
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002520bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2521 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2522 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002523 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002524 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002525
2526 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2527 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2528 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2529 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002530 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2531 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2532 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2533 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2534 ++descriptor_index) {
2535 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07002536 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002537 "vkCreateDescriptorSetLayout: required parameter "
2538 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2539 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002540 }
2541 }
2542 }
2543
2544 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2545 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2546 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002547 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2548 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2549 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2550 "values.",
2551 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002552 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07002553
2554 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
2555 (pCreateInfo->pBindings[i].stageFlags != 0) &&
2556 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
2557 skip |=
2558 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
2559 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
2560 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
2561 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
2562 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
2563 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002564 }
2565 }
2566 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002567 return skip;
2568}
2569
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002570bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2571 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002572 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002573 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2574 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2575 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002576 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2577 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002578}
2579
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002580bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2581 const VkWriteDescriptorSet *pDescriptorWrites,
2582 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002583 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002584
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002585 if (pDescriptorWrites != NULL) {
2586 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2587 // descriptorCount must be greater than 0
2588 if (pDescriptorWrites[i].descriptorCount == 0) {
2589 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002590 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2591 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002592 }
2593
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002594 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2595 if (validateDstSet) {
2596 // dstSet must be a valid VkDescriptorSet handle
2597 skip |= validate_required_handle(vkCallingFunction,
2598 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2599 pDescriptorWrites[i].dstSet);
2600 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002601
2602 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2603 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2604 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2605 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2606 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2607 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2608 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05002609 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
2610 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002611 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002612 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2613 "%s(): if pDescriptorWrites[%d].descriptorType is "
2614 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2615 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2616 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2617 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002618 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2619 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05002620 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
2621 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002622 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2623 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002624 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002625 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2626 ParameterName::IndexVector{i, descriptor_index}),
2627 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002628 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002629 }
2630 }
2631 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2632 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2633 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2634 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2635 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2636 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2637 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05002638 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002639 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002640 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2641 "%s(): if pDescriptorWrites[%d].descriptorType is "
2642 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2643 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2644 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2645 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002646 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05002647 const auto *robustness2_features =
2648 lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
2649 if (robustness2_features && robustness2_features->nullDescriptor) {
2650 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount;
2651 ++descriptorIndex) {
2652 if (pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer == VK_NULL_HANDLE &&
2653 (pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset != 0 ||
2654 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range != VK_WHOLE_SIZE)) {
2655 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
2656 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
2657 "offset (" PRIu64 ") must be zero and range (" PRIu64 ") must be VK_WHOLE_SIZE.",
2658 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset,
2659 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range);
2660 }
2661 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002662 }
2663 }
2664 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2665 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05002666 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002667 }
2668
2669 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2670 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002671 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002672 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2673 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2674 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002675 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002676 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2677 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2678 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2679 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002680 }
2681 }
2682 }
2683 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2684 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002685 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002686 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2687 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2688 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002689 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002690 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
2691 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2692 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2693 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002694 }
2695 }
2696 }
2697 }
sourav parmara96ab1a2020-04-25 16:28:23 -07002698 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
2699 // or VkWriteDescriptorSetInlineUniformBlockEX
2700 if (pDescriptorWrites[i].pNext) {
2701 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
2702 const auto *pNext_struct =
2703 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
2704 if (!pNext_struct || (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
2705 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
2706 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
2707 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
2708 "accelerationStructureCount %d member equals descriptorCount %d.",
2709 vkCallingFunction, pNext_struct ? pNext_struct->accelerationStructureCount : -1,
2710 pDescriptorWrites[i].descriptorCount);
2711 }
2712 // further checks only if we have right structtype
2713 if (pNext_struct) {
2714 if (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
2715 skip |= LogError(
2716 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
2717 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
2718 ".",
2719 vkCallingFunction, pNext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
2720 }
2721 if (pNext_struct->accelerationStructureCount == 0) {
2722 skip |= LogError(
2723 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
2724 "%s(): accelerationStructureCount must be greater than 0 .");
2725 }
2726 }
2727 }
2728 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002729 }
2730 }
2731 return skip;
2732}
2733
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002734bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
2735 const VkWriteDescriptorSet *pDescriptorWrites,
2736 uint32_t descriptorCopyCount,
2737 const VkCopyDescriptorSet *pDescriptorCopies) const {
2738 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
2739}
2740
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002741bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002742 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002743 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002744 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
2745}
2746
2747bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002748 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002749 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002750 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
2751}
2752
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002753bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
2754 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002755 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002756 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002757
2758 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2759 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2760 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002761 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
2762 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002763 return skip;
2764}
2765
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002766bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002767 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002768 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02002769
2770 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
2771 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002772 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
2773
Petr Krause7bb9e82019-08-11 21:34:43 +02002774 // Implicit VUs
2775 // validate only sType here; pointer has to be validated in core_validation
2776 const bool kNotRequired = false;
2777 const char *kNoVUID = nullptr;
2778 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
2779 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
2780 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002781
Petr Krause7bb9e82019-08-11 21:34:43 +02002782 if (pInfo) {
2783 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
2784 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
2785 skip |= validate_struct_pnext(
2786 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
2787 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08002788 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
2789 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002790
Petr Krause7bb9e82019-08-11 21:34:43 +02002791 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002792
Petr Krause7bb9e82019-08-11 21:34:43 +02002793 // Explicit VUs
2794 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002795 skip |= LogError(
2796 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02002797 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
2798 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002799 }
Petr Krause7bb9e82019-08-11 21:34:43 +02002800
2801 if (physical_device_features.inheritedQueries) {
2802 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002803 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06002804 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02002805 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02002806 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002807 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02002808 }
2809
2810 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02002811 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002812 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002813 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02002814 } else { // !pipelineStatisticsQuery
2815 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
2816 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002817 }
Petr Kraus139757b2019-08-15 17:19:33 +02002818
2819 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
2820 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002821 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02002822 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
2823 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002824 skip |= LogError(
2825 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02002826 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
2827 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
2828 }
2829 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002830 }
2831
2832 return skip;
2833}
2834
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002835bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002836 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002837 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002838
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002839 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01002840 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002841 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
2842 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
2843 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01002844 }
2845 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002846 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
2847 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
2848 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01002849 }
2850 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01002851 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002852 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002853 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
2854 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2855 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2856 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002857 }
2858 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01002859
2860 if (pViewports) {
2861 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
2862 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002863 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002864 skip |= manual_PreCallValidateViewport(
2865 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01002866 }
2867 }
2868
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002869 return skip;
2870}
2871
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002872bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002873 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002874 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002875
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002876 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002877 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002878 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
2879 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
2880 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002881 }
2882 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002883 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
2884 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
2885 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002886 }
2887 } else { // multiViewport enabled
2888 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002889 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002890 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
2891 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2892 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2893 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002894 }
2895 }
2896
Petr Kraus6260f0a2018-02-27 21:15:55 +01002897 if (pScissors) {
2898 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
2899 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002900
Petr Kraus6260f0a2018-02-27 21:15:55 +01002901 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002902 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2903 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
2904 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002905 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002906
Petr Kraus6260f0a2018-02-27 21:15:55 +01002907 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002908 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2909 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
2910 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002911 }
2912
2913 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2914 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002915 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
2916 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2917 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2918 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002919 }
2920
2921 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2922 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002923 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
2924 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2925 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2926 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002927 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002928 }
2929 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01002930
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002931 return skip;
2932}
2933
Jeff Bolz5c801d12019-10-09 10:38:45 -05002934bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01002935 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01002936
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002937 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002938 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
2939 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002940 }
2941
2942 return skip;
2943}
2944
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002945bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002946 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002947 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002948 if (vertexCount == 0) {
2949 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
2950 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002951 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002952 }
2953
2954 if (instanceCount == 0) {
2955 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
2956 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002957 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002958 }
2959 return skip;
2960}
2961
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002962bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002963 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002964 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002965
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002966 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002967 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2968 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002969 }
2970 return skip;
2971}
2972
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002973bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002974 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002975 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002976 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002977 skip |=
2978 LogError(device, kVUID_PVError_DeviceFeature,
2979 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002980 }
2981 return skip;
2982}
2983
sfricke-samsungf692b972020-05-02 08:00:45 -07002984bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
2985 VkDeviceSize countBufferOffset, bool khr) const {
2986 bool skip = false;
2987 const char *apiName = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
2988 if (offset & 3) {
2989 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
2990 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
2991 }
2992
2993 if (countBufferOffset & 3) {
2994 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
2995 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
2996 countBufferOffset);
2997 }
2998 return skip;
2999}
3000
3001bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(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, false);
3006}
3007
3008bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3009 VkDeviceSize offset, VkBuffer countBuffer,
3010 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3011 uint32_t stride) const {
3012 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3013}
3014
3015bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3016 VkDeviceSize countBufferOffset, bool khr) const {
3017 bool skip = false;
3018 const char *apiName = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
3019 if (offset & 3) {
3020 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
3021 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3022 }
3023
3024 if (countBufferOffset & 3) {
3025 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
3026 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3027 countBufferOffset);
3028 }
3029 return skip;
3030}
3031
3032bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3033 VkDeviceSize offset, VkBuffer countBuffer,
3034 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3035 uint32_t stride) const {
3036 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3037}
3038
3039bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3040 VkDeviceSize offset, VkBuffer countBuffer,
3041 VkDeviceSize countBufferOffset,
3042 uint32_t maxDrawCount, uint32_t stride) const {
3043 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3044}
3045
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003046bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3047 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003048 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003049 bool skip = false;
3050 for (uint32_t rect = 0; rect < rectCount; rect++) {
3051 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003052 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3053 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003054 }
sfricke-samsung10867682020-04-25 02:20:39 -07003055 if (pRects[rect].rect.extent.width == 0) {
3056 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3057 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3058 }
3059 if (pRects[rect].rect.extent.height == 0) {
3060 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3061 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3062 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003063 }
3064 return skip;
3065}
3066
Andrew Fobel3abeb992020-01-20 16:33:22 -05003067bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3068 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3069 VkImageFormatProperties2 *pImageFormatProperties,
3070 const char *apiName) const {
3071 bool skip = false;
3072
3073 if (pImageFormatInfo != nullptr) {
3074 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
3075 if (image_stencil_struct != nullptr) {
3076 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3077 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3078 // No flags other than the legal attachment bits may be set
3079 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3080 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003081 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3082 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3083 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3084 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3085 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003086 }
3087 }
3088 }
3089 }
3090
3091 return skip;
3092}
3093
3094bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3095 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3096 VkImageFormatProperties2 *pImageFormatProperties) const {
3097 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3098 "vkGetPhysicalDeviceImageFormatProperties2");
3099}
3100
3101bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3102 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3103 VkImageFormatProperties2 *pImageFormatProperties) const {
3104 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3105 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3106}
3107
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003108bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3109 VkImageLayout srcImageLayout, VkImage dstImage,
3110 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003111 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003112 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003113
Dave Houltonf5217612018-02-02 16:18:52 -07003114 VkImageAspectFlags legal_aspect_flags =
3115 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 -07003116 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003117 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3118 }
3119
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003120 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003121 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003122 skip |= LogError(
3123 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003124 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003125 }
Dave Houltonf5217612018-02-02 16:18:52 -07003126 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003127 skip |= LogError(
3128 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003129 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003130 }
3131 }
3132 return skip;
3133}
3134
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003135bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3136 VkImageLayout srcImageLayout, VkImage dstImage,
3137 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003138 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003139 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003140
Dave Houltonf5217612018-02-02 16:18:52 -07003141 VkImageAspectFlags legal_aspect_flags =
3142 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 -07003143 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003144 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3145 }
3146
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003147 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003148 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003149 skip |= LogError(
3150 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003151 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
3152 }
Dave Houltonf5217612018-02-02 16:18:52 -07003153 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003154 skip |= LogError(
3155 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003156 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
3157 }
3158 }
3159 return skip;
3160}
3161
sfricke-samsung3999ef62020-02-09 17:05:59 -08003162bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3163 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3164 bool skip = false;
3165
3166 if (pRegions != nullptr) {
3167 for (uint32_t i = 0; i < regionCount; i++) {
3168 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003169 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3170 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003171 }
3172 }
3173 }
3174 return skip;
3175}
3176
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003177bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
3178 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003179 uint32_t regionCount,
3180 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003181 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003182
Dave Houltonf5217612018-02-02 16:18:52 -07003183 VkImageAspectFlags legal_aspect_flags =
3184 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 -07003185 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003186 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3187 }
3188
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003189 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003190 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003191 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
3192 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
3193 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003194 }
3195 }
3196 return skip;
3197}
3198
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003199bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
3200 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003201 uint32_t regionCount,
3202 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003203 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003204
Dave Houltonf5217612018-02-02 16:18:52 -07003205 VkImageAspectFlags legal_aspect_flags =
3206 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 -07003207 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003208 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3209 }
3210
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003211 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003212 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Petr Kraus3e6cd032020-04-14 20:41:16 +02003213 skip |= LogError(
3214 device, kVUID_PVError_UnrecognizedValue,
3215 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
3216 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003217 }
3218 }
3219 return skip;
3220}
3221
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003222bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003223 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3224 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003225 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003226
3227 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003228 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3229 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3230 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003231 }
3232
3233 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003234 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3235 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3236 "), must be greater than zero and less than or equal to 65536.",
3237 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003238 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003239 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3240 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3241 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003242 }
3243 return skip;
3244}
3245
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003246bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003247 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003248 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003249
3250 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003251 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3252 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3253 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003254 }
3255
3256 if (size != VK_WHOLE_SIZE) {
3257 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003258 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003259 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3260 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003261 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003262 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3263 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003264 }
3265 }
3266 return skip;
3267}
3268
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003269bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003270 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003271 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003272 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003273
3274 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003275 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3276 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3277 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3278 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003279 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3280 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3281 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003282 }
3283
3284 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3285 // queueFamilyIndexCount uint32_t values
3286 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003287 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3288 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3289 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3290 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003291 }
3292 }
3293
Dave Houlton413a6782018-05-22 13:01:54 -06003294 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003295 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003296 }
3297
3298 return skip;
3299}
3300
Jeff Bolz5c801d12019-10-09 10:38:45 -05003301bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003302 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003303
3304 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003305 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3306 if (present_regions) {
3307 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003308 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003309 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3310 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003311 skip |= LogError(device, kVUID_PVError_InvalidUsage,
3312 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3313 "extension swapchainCount is %i. These values must be equal.",
3314 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003315 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003316 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003317 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3318 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003319 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3320 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3321 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003322 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003323 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003324 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003325 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003326 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003327 }
3328 }
3329
3330 return skip;
3331}
3332
3333#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003334bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3335 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3336 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003337 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003338 bool skip = false;
3339
3340 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003341 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3342 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003343 }
3344
3345 return skip;
3346}
3347#endif // VK_USE_PLATFORM_WIN32_KHR
3348
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003349bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003350 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003351 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003352 bool skip = false;
3353
3354 if (pCreateInfo) {
3355 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003356 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3357 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003358 }
3359
3360 if (pCreateInfo->pPoolSizes) {
3361 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3362 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003363 skip |= LogError(
3364 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003365 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003366 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003367 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3368 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003369 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3370 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3371 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3372 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3373 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003374 }
Petr Krausc8655be2017-09-27 18:56:51 +02003375 }
3376 }
3377 }
3378
3379 return skip;
3380}
3381
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003382bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003383 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003384 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003385
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003386 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003387 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003388 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3389 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3390 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003391 }
3392
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003393 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003394 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003395 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3396 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3397 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003398 }
3399
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003400 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003401 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003402 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3403 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3404 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003405 }
3406
3407 return skip;
3408}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003409
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003410bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003411 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003412 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003413
3414 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003415 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3416 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003417 }
3418 return skip;
3419}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003420
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003421bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3422 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003423 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003424 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003425
3426 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003427 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003428 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003429 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3430 "vkCmdDispatch(): baseGroupX (%" PRIu32
3431 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3432 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003433 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003434 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3435 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3436 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3437 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003438 }
3439
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003440 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003441 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003442 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3443 "vkCmdDispatch(): baseGroupY (%" PRIu32
3444 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3445 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003446 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003447 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3448 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3449 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3450 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003451 }
3452
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003453 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003454 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003455 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3456 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3457 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3458 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003459 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003460 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3461 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3462 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3463 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003464 }
3465
3466 return skip;
3467}
3468
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003469bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3470 VkPipelineBindPoint pipelineBindPoint,
3471 VkPipelineLayout layout, uint32_t set,
3472 uint32_t descriptorWriteCount,
3473 const VkWriteDescriptorSet *pDescriptorWrites) const {
3474 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3475}
3476
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003477bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3478 uint32_t firstExclusiveScissor,
3479 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003480 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003481 bool skip = false;
3482
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003483 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003484 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003485 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003486 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3487 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3488 ") is not 0.",
3489 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003490 }
3491 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003492 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003493 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3494 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3495 ") is not 1.",
3496 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003497 }
3498 } else { // multiViewport enabled
3499 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003500 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003501 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3502 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3503 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3504 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003505 }
3506 }
3507
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003508 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003509 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3510 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3511 ") must be less than maxViewports (=%" PRIu32 ").",
3512 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003513 }
3514
3515 if (pExclusiveScissors) {
3516 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3517 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3518
3519 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003520 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3521 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3522 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003523 }
3524
3525 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003526 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3527 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3528 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003529 }
3530
3531 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3532 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003533 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3534 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3535 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3536 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003537 }
3538
3539 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3540 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003541 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3542 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3543 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3544 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003545 }
3546 }
3547 }
3548
3549 return skip;
3550}
3551
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003552bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3553 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003554 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003555 bool skip = false;
3556 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003557 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3558 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3559 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003560 } else {
3561 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3562 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003563 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3564 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3565 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3566 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003567 }
3568 }
3569
3570 return skip;
3571}
3572
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003573bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3574 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003575 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003576 bool skip = false;
3577
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003578 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003579 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003580 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003581 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3582 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3583 ") is not 0.",
3584 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003585 }
3586 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003587 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003588 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3589 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3590 ") is not 1.",
3591 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003592 }
3593 }
3594
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003595 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003596 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3597 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3598 ") must be less than maxViewports (=%" PRIu32 ").",
3599 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003600 }
3601
3602 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003603 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003604 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3605 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3606 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3607 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003608 }
3609
3610 return skip;
3611}
3612
Jeff Bolz5c801d12019-10-09 10:38:45 -05003613bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3614 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3615 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003616 bool skip = false;
3617
Dave Houlton142c4cb2018-10-17 15:04:41 -06003618 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003619 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3620 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3621 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003622 }
3623
3624 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003625 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003626 }
3627
3628 return skip;
3629}
3630
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003631bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003632 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003633 bool skip = false;
3634
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003635 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003636 skip |= LogError(
3637 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003638 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3639 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003640 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003641 }
3642
3643 return skip;
3644}
3645
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003646bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3647 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003648 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003649 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003650 static const int condition_multiples = 0b0011;
3651 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003652 skip |= LogError(
3653 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003654 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003655 }
Lockee1c22882019-06-10 16:02:54 -06003656 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003657 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3658 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3659 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3660 stride);
Lockee1c22882019-06-10 16:02:54 -06003661 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003662 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003663 skip |= LogError(
3664 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3665 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003666 }
3667
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003668 return skip;
3669}
3670
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003671bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3672 VkDeviceSize offset, VkBuffer countBuffer,
3673 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003674 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003675 bool skip = false;
3676
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003677 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003678 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3679 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3680 "), is not a multiple of 4.",
3681 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003682 }
3683
3684 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003685 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
3686 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3687 "), is not a multiple of 4.",
3688 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003689 }
3690
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003691 return skip;
3692}
3693
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003694bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003695 const VkAllocationCallbacks *pAllocator,
3696 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003697 bool skip = false;
3698
3699 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3700 if (pCreateInfo != nullptr) {
3701 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3702 // VkQueryPipelineStatisticFlagBits values
3703 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3704 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003705 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
3706 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3707 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3708 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003709 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07003710 if (pCreateInfo->queryCount == 0) {
3711 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
3712 "vkCreateQueryPool(): queryCount must be greater than zero.");
3713 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003714 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003715 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003716}
3717
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003718bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3719 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003720 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003721 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3722 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003723}
3724
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003725void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003726 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3727 VkResult result) {
3728 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003729 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003730}
3731
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003732void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003733 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3734 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003735 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003736 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003737 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003738}
3739
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003740void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
3741 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003742 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003743 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003744 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003745}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003746
3747bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003748 const VkAllocationCallbacks *pAllocator,
3749 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003750 bool skip = false;
3751
3752 if (pAllocateInfo) {
3753 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
3754 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003755 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
3756 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003757 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003758
3759 VkMemoryAllocateFlags flags = 0;
3760 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
3761 if (flags_info) {
3762 flags = flags_info->flags;
3763 }
3764
3765 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
3766 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
3767 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003768 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
3769 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
3770 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003771 }
3772
3773#ifdef VK_USE_PLATFORM_WIN32_KHR
3774 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
3775#endif
3776 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
3777 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
3778#ifdef VK_USE_PLATFORM_ANDROID_KHR
3779 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
3780#endif
3781
3782 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003783 skip |= LogError(
3784 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003785 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
3786 }
3787 if (
3788#ifdef VK_USE_PLATFORM_WIN32_KHR
3789 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
3790#endif
3791 (import_memory_fd && import_memory_fd->handleType) ||
3792#ifdef VK_USE_PLATFORM_ANDROID_KHR
3793 (import_memory_ahb && import_memory_ahb->buffer) ||
3794#endif
3795 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003796 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
3797 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003798 }
3799 }
3800
3801 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003802 VkBool32 capture_replay = false;
3803 VkBool32 buffer_device_address = false;
3804 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
3805 if (vulkan_12_features) {
3806 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
3807 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
3808 } else {
3809 const auto *bda_features =
3810 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
3811 if (bda_features) {
3812 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
3813 buffer_device_address = bda_features->bufferDeviceAddress;
3814 }
3815 }
3816 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003817 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
3818 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
3819 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003820 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003821 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003822 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
3823 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003824 }
3825 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003826 }
3827 return skip;
3828}
Ricardo Garciaa4935972019-02-21 17:43:18 +01003829
Jason Macnak192fa0e2019-07-26 15:07:16 -07003830bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003831 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003832 bool skip = false;
3833
3834 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
3835 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
3836 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003837 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003838 } else {
3839 uint32_t vertex_component_size = 0;
3840 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
3841 vertex_component_size = 4;
3842 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
3843 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
3844 vertex_component_size = 2;
3845 }
3846 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003847 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003848 }
3849 }
3850
3851 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
3852 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003853 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003854 } else {
3855 uint32_t index_element_size = 0;
3856 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
3857 index_element_size = 4;
3858 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
3859 index_element_size = 2;
3860 }
3861 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003862 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003863 }
3864 }
3865 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
3866 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003867 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003868 }
3869 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003870 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003871 }
3872 }
3873
3874 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003875 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003876 }
3877
3878 return skip;
3879}
3880
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003881bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
3882 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003883 bool skip = false;
3884
3885 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003886 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003887 }
3888 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003889 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003890 }
3891
3892 return skip;
3893}
3894
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003895bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
3896 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003897 bool skip = false;
3898 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003899 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003900 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003901 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003902 }
3903 return skip;
3904}
3905
3906bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003907 VkAccelerationStructureNV object_handle,
Jason Macnak192fa0e2019-07-26 15:07:16 -07003908 const char *func_name) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003909 bool skip = false;
3910 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003911 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
3912 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
3913 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003914 }
3915 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003916 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
3917 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
3918 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003919 }
3920 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
3921 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003922 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
3923 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
3924 "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 -07003925 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003926 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003927 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
3928 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
3929 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003930 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003931 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003932 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
3933 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
3934 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003935 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003936 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07003937 uint64_t total_triangle_count = 0;
3938 for (uint32_t i = 0; i < info.geometryCount; i++) {
3939 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07003940
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003941 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003942
Jason Macnak5c954952019-07-09 15:46:12 -07003943 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
3944 continue;
3945 }
3946 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
3947 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003948 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003949 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
3950 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
3951 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003952 }
3953 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003954 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
3955 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
3956 for (uint32_t i = 1; i < info.geometryCount; i++) {
3957 const VkGeometryNV &geometry = info.pGeometries[i];
3958 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003959 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003960 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
3961 "info.pGeometries[0].geometryType.",
3962 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07003963 }
3964 }
3965 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003966 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
3967 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
3968 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
3969 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
3970 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
3971 "or VK_GEOMETRY_TYPE_AABBS_NV.");
3972 }
3973 }
3974 skip |=
3975 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
3976 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-03486");
Jason Macnak5c954952019-07-09 15:46:12 -07003977 return skip;
3978}
3979
Ricardo Garciaa4935972019-02-21 17:43:18 +01003980bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
3981 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003982 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01003983 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01003984 if (pCreateInfo) {
3985 if ((pCreateInfo->compactedSize != 0) &&
3986 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003987 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
3988 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
3989 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
3990 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01003991 }
Jason Macnak5c954952019-07-09 15:46:12 -07003992
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003993 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
Jason Macnak192fa0e2019-07-26 15:07:16 -07003994 "vkCreateAccelerationStructureNV()");
Ricardo Garciaa4935972019-02-21 17:43:18 +01003995 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01003996 return skip;
3997}
Mike Schuchardt21638df2019-03-16 10:52:02 -07003998
Jeff Bolz5c801d12019-10-09 10:38:45 -05003999bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4000 const VkAccelerationStructureInfoNV *pInfo,
4001 VkBuffer instanceData, VkDeviceSize instanceOffset,
4002 VkBool32 update, VkAccelerationStructureNV dst,
4003 VkAccelerationStructureNV src, VkBuffer scratch,
4004 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004005 bool skip = false;
4006
4007 if (pInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004008 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()");
Jason Macnak5c954952019-07-09 15:46:12 -07004009 }
4010
4011 return skip;
4012}
4013
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004014bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4015 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4016 VkAccelerationStructureKHR *pAccelerationStructure) const {
4017 bool skip = false;
4018
4019 if (pCreateInfo) {
4020 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
4021 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4022 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4023 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
4024 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
4025 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4026 i);
4027 }
4028 }
4029
4030 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4031 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4032 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
4033 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
4034 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4035 i);
4036 }
4037 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004038 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
4039 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
4040 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
4041 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
4042 skip |= LogError(
4043 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
4044 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
4045 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
4046 }
4047 }
4048 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
4049 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
4050 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
4051 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4052 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
4053 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
4054 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
4055 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
4056 }
4057 }
4058 }
4059
4060 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
4061 pCreateInfo->maxGeometryCount != 1) {
4062 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
4063 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4064 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004065 }
4066
4067 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
4068 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
4069 skip |= LogError(
4070 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
4071 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
4072 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
4073 }
4074
4075 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
4076 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
4077 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
4078 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
4079 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
4080 }
4081
4082 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
4083 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
4084 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
4085 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
4086 if (geometry_type != first_geometry_type) {
4087 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
4088 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
4089 "pGeometryInfos[0].geometryType.",
4090 i);
4091 }
4092 }
4093 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004094 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
4095 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
4096 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
4097 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
4098 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
4099 "maxGeometryCount %d.",
4100 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
4101 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004102 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004103 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4104 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
4105 if (pCreateInfo->deviceAddress != 0) {
4106 skip |=
4107 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
4108 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
4109 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
4110 }
4111 }
sourav parmar83c31b12020-05-06 12:30:54 -07004112 if (!raytracing_features || !(raytracing_features->rayQuery == VK_TRUE || raytracing_features->rayTracing == VK_TRUE)) {
4113 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-rayTracing-03487",
4114 "vkCreateAccelerationStructureKHR: The rayTracing or rayQuery feature must be enabled.");
4115 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004116 return skip;
4117}
4118
Jason Macnak5c954952019-07-09 15:46:12 -07004119bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4120 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004121 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004122 bool skip = false;
4123 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004124 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4125 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004126 }
4127 return skip;
4128}
4129
Peter Chen85366392019-05-14 15:20:11 -04004130bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4131 uint32_t createInfoCount,
4132 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4133 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004134 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004135 bool skip = false;
4136
4137 for (uint32_t i = 0; i < createInfoCount; i++) {
4138 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4139 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004140 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004141 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4142 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4143 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4144 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004145 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004146
4147 const auto *pipeline_cache_contol_features =
4148 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4149 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4150 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4151 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4152 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4153 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4154 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4155 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4156 }
4157 }
4158
sourav parmarf4a78252020-04-10 13:04:21 -07004159 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4160 skip |=
4161 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4162 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4163 }
4164 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4165 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4166 skip |=
4167 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4168 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4169 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4170 }
4171 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4172 if (pCreateInfos[i].basePipelineIndex != -1) {
4173 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4174 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4175 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4176 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4177 "and pCreateInfos->basePipelineIndex is not -1.");
4178 }
4179 }
4180 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4181 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4182 skip |=
4183 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4184 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4185 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4186 "commands pCreateInfos parameter.");
4187 }
4188 } else {
4189 if (pCreateInfos[i].basePipelineIndex != -1) {
4190 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4191 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4192 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4193 }
4194 }
4195 }
4196 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4197 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4198 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4199 }
4200 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4201 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4202 "vkCreateRayTracingPipelinesNV: flags must not include "
4203 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4204 }
4205 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4206 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4207 "vkCreateRayTracingPipelinesNV: flags must not include "
4208 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4209 }
4210 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4211 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4212 "vkCreateRayTracingPipelinesNV: flags must not include "
4213 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4214 }
4215 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4216 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4217 "vkCreateRayTracingPipelinesNV: flags must not include "
4218 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4219 }
4220 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4221 skip |= LogError(
4222 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4223 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4224 }
4225 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4226 skip |= LogError(
4227 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4228 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4229 }
Peter Chen85366392019-05-14 15:20:11 -04004230 }
4231
4232 return skip;
4233}
4234
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004235bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4236 uint32_t createInfoCount,
4237 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4238 const VkAllocationCallbacks *pAllocator,
4239 VkPipeline *pPipelines) const {
4240 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004241 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4242 if (!raytracing_features || raytracing_features->rayTracing == VK_FALSE) {
4243 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracing-03455",
4244 "vkCreateRayTracingPipelinesKHR(): The rayTracing feature must be enabled.");
4245 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004246 for (uint32_t i = 0; i < createInfoCount; i++) {
4247 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4248 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4249 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4250 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4251 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4252 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4253 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4254 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004255 const auto *pipeline_cache_contol_features =
4256 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4257 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4258 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4259 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4260 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4261 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4262 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4263 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4264 }
4265 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004266 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4267 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4268 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4269 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4270 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4271 }
4272 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4273 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4274 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4275 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4276 }
4277 }
4278
sourav parmarf4a78252020-04-10 13:04:21 -07004279 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4280 skip |=
4281 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4282 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4283 }
4284 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4285 if (pCreateInfos[i].pLibraryInterface == NULL)
4286 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4287 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4288 }
4289 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4290 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4291 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4292 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4293 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4294 skip |= LogError(
4295 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4296 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4297 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4298 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4299 "must not be VK_SHADER_UNUSED_KHR");
4300 }
4301 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4302 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4303 skip |= LogError(
4304 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4305 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4306 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4307 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4308 "element must not be VK_SHADER_UNUSED_KHR");
4309 }
4310 }
4311 }
4312 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4313 if (pCreateInfos[i].basePipelineIndex != -1) {
4314 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4315 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4316 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4317 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4318 "and pCreateInfos->basePipelineIndex is not -1.");
4319 }
4320 }
4321 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4322 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4323 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4324 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4325 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4326 "commands pCreateInfos parameter %d.",
4327 pCreateInfos[i].basePipelineIndex, createInfoCount);
4328 }
4329 } else {
4330 if (pCreateInfos[i].basePipelineIndex != -1) {
4331 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4332 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4333 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4334 }
4335 }
4336 }
4337 if (pCreateInfos[i].libraries.libraryCount == 0) {
4338 if (pCreateInfos[i].stageCount == 0) {
4339 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4340 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4341 }
4342 if (pCreateInfos[i].groupCount == 0) {
4343 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4344 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4345 }
4346 } else {
4347 if (pCreateInfos[i].pLibraryInterface == NULL) {
4348 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4349 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4350 }
4351 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004352 }
4353
4354 return skip;
4355}
4356
Mike Schuchardt21638df2019-03-16 10:52:02 -07004357#ifdef VK_USE_PLATFORM_WIN32_KHR
4358bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4359 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004360 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004361 bool skip = false;
4362 if (!device_extensions.vk_khr_swapchain)
4363 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4364 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4365 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4366 if (!device_extensions.vk_khr_surface)
4367 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4368 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4369 skip |=
4370 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4371 if (!device_extensions.vk_ext_full_screen_exclusive)
4372 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4373 skip |= validate_struct_type(
4374 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4375 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4376 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4377 if (pSurfaceInfo != NULL) {
4378 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4379 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4380 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4381
4382 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4383 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4384 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4385 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004386 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4387 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004388
4389 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4390 }
4391 return skip;
4392}
4393#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004394
4395bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4396 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004397 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004398 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4399 bool skip = false;
4400 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4401 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4402 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4403 }
4404 return skip;
4405}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004406
4407bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004408 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004409 bool skip = false;
4410
4411 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004412 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4413 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004414 }
4415
4416 return skip;
4417}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004418
4419bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004420 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004421 bool skip = false;
4422
4423 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004424 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4425 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004426 }
4427
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004428 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06004429 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004430 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4431 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004432 }
4433
4434 return skip;
4435}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004436
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004437bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4438 uint32_t bindingCount, const VkBuffer *pBuffers,
4439 const VkDeviceSize *pOffsets) const {
4440 bool skip = false;
4441 if (firstBinding > device_limits.maxVertexInputBindings) {
4442 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4443 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4444 device_limits.maxVertexInputBindings);
4445 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4446 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4447 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4448 "maxVertexInputBindings (%u)",
4449 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4450 }
4451
Jeff Bolz165818a2020-05-08 11:19:03 -05004452 for (uint32_t i = 0; i < bindingCount; ++i) {
4453 if (pBuffers[i] == VK_NULL_HANDLE) {
4454 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
4455 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
4456 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
4457 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
4458 } else {
4459 if (pOffsets[i] != 0) {
4460 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
4461 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
4462 }
4463 }
4464 }
4465 }
4466
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004467 return skip;
4468}
4469
Mark Lobodzinski84988402019-09-11 15:27:30 -06004470bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004471 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004472 bool skip = false;
4473 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004474 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4475 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004476 }
4477 return skip;
4478}
4479
4480bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004481 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004482 bool skip = false;
4483 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004484 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4485 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004486 }
4487 return skip;
4488}
Petr Kraus3d720392019-11-13 02:52:39 +01004489
4490bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4491 VkSemaphore semaphore, VkFence fence,
4492 uint32_t *pImageIndex) const {
4493 bool skip = false;
4494
4495 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004496 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4497 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004498 }
4499
4500 return skip;
4501}
4502
4503bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4504 uint32_t *pImageIndex) const {
4505 bool skip = false;
4506
4507 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004508 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4509 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004510 }
4511
4512 return skip;
4513}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004514
4515bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
4516 uint32_t firstInstance, VkBuffer counterBuffer,
4517 VkDeviceSize counterBufferOffset,
4518 uint32_t counterOffset, uint32_t vertexStride) const {
4519 bool skip = false;
4520
4521 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004522 skip |= LogError(
4523 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004524 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
4525 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
4526 }
4527
4528 return skip;
4529}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004530
4531bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
4532 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4533 const VkAllocationCallbacks *pAllocator,
4534 VkSamplerYcbcrConversion *pYcbcrConversion,
4535 const char *apiName) const {
4536 bool skip = false;
4537
4538 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004539 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004540 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004541 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
4542 "samplerYcbcrConversion must be enabled to call %s.", apiName);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004543 }
4544 return skip;
4545}
4546
4547bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
4548 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4549 const VkAllocationCallbacks *pAllocator,
4550 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4551 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4552 "vkCreateSamplerYcbcrConversion");
4553}
4554
4555bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
4556 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4557 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4558 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4559 "vkCreateSamplerYcbcrConversionKHR");
4560}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004561
4562bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
4563 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
4564 bool skip = false;
4565 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
4566 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
4567
4568 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004569 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
4570 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
4571 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
4572 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
4573 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004574 }
4575 return skip;
4576}
sourav parmara96ab1a2020-04-25 16:28:23 -07004577
4578bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
4579 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4580 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004581 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4582 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4583 skip |=
4584 LogError(device, "", "VUID-vkCopyAccelerationStructureToMemoryKHR-rayTracingHostAccelerationStructureCommands-03447",
4585 "vkCopyAccelerationStructureToMemoryKHR: the "
4586 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
4587 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004588 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4589 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4590 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4591 }
4592 return skip;
4593}
4594
4595bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
4596 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4597 bool skip = false;
4598 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4599 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
4600 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4601 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4602 }
sourav parmar83c31b12020-05-06 12:30:54 -07004603 const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
4604 if (pNext_struct) {
4605 skip |= LogError(
4606 commandBuffer, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pNext-03560",
4607 "vkCmdCopyAccelerationStructureToMemoryKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
4608 "pNext chain of the VkCopyAccelerationStructureToMemoryInfoKHR structure.");
4609 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004610 return skip;
4611}
4612
4613bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
4614 const char *api_name) const {
4615 bool skip = false;
4616 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
4617 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
4618 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
4619 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
4620 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
4621 api_name);
4622 }
4623 return skip;
4624}
4625
4626bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
4627 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4628 bool skip = false;
4629 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
sourav parmar83c31b12020-05-06 12:30:54 -07004630 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4631 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4632 skip |= LogError(
4633 device, "VUID-vkCopyAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03441",
4634 "vkCopyAccelerationStructureKHR(): the "
4635 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled .");
4636 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004637 return skip;
4638}
4639
4640bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
4641 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4642 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004643 const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
4644 if (pNext_struct) {
4645 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureKHR-pNext-03557",
4646 "vkCmdCopyAccelerationStructureKHR(): The VkDeferredOperationInfoKHR structure must not be included in "
4647 "the pNext chain of the VkCopyAccelerationStructureInfoKHR structure.");
4648 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004649 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
4650 return skip;
4651}
4652
4653bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
sourav parmar83c31b12020-05-06 12:30:54 -07004654 const char *api_name, bool isCmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07004655 bool skip = false;
4656 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07004657 skip |= LogError(device,
4658 isCmd ? "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-mode-03413"
4659 : "VUID-vkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07004660 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
4661 }
4662 return skip;
4663}
4664
4665bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
4666 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4667 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004668 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
4669 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4670 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4671 skip |=
4672 LogError(device, "VUID-vkCopyMemoryToAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03444",
4673 "vkCopyMemoryToAccelerationStructureKHR() :the "
4674 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
4675 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004676 return skip;
4677}
4678bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
4679 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4680 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004681 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
4682 return skip;
4683}
4684bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
4685 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
4686 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
4687 bool skip = false;
4688 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
4689 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
4690 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
4691 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
4692 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
4693 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
4694 }
4695 return skip;
4696}
4697bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
4698 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
4699 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
4700 bool skip = false;
4701 if (dataSize < accelerationStructureCount * stride) {
4702 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
4703 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
4704 "accelerationStructureCount (%d) *stride(%zu).",
4705 dataSize, accelerationStructureCount, stride);
4706 }
4707 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
4708 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
4709 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
4710 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
4711 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
4712 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
4713 }
4714 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
4715 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
4716 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
4717 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
4718 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
4719 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
4720 stride);
4721 }
4722 }
4723 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
4724 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
4725 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
4726 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
4727 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
4728 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
4729 stride);
4730 }
4731 }
4732 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4733 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4734 skip |=
4735 LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-rayTracingHostAccelerationStructureCommands-03454",
4736 "vkWriteAccelerationStructuresPropertiesKHR: the "
4737 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
4738 "feature must be enabled ");
4739 }
4740 return skip;
4741}
4742bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
4743 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
4744 bool skip = false;
4745 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4746 if (!raytracing_features || raytracing_features->rayTracingShaderGroupHandleCaptureReplay == VK_FALSE) {
4747 skip |= LogError(device,
4748 "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingShaderGroupHandleCaptureReplay-03485",
4749 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR: "
4750 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingShaderGroupHandleCaptureReplay"
4751 "must be enabled to call this function.");
4752 }
4753 return skip;
4754}
4755
4756bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
4757 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
4758 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
4759 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
4760 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
4761 uint32_t width, uint32_t height, uint32_t depth) const {
4762 bool skip = false;
4763 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4764 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04038",
4765 "vkCmdTraceRaysKHR: The offset member of pCallableShaderBindingTable"
4766 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4767 }
4768 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
4769 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04040",
4770 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple"
4771 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
4772 }
4773 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
4774 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
4775 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
4776 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
4777 }
4778 // hitShader
4779 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4780 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04032",
4781 "vkCmdTraceRaysKHR: The offset member of pHitShaderBindingTable must be a multiple"
4782 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4783 }
4784 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
4785 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04034",
4786 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple"
4787 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
4788 }
4789 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
4790 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
4791 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be"
4792 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
4793 }
4794
4795 // missShader
4796 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4797 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04026",
4798 "vkCmdTraceRaysKHR: The offset member of pMissShaderBindingTable must be a multiple"
4799 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4800 }
4801 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
4802 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04028",
4803 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple"
4804 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
4805 }
4806 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
4807 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
4808 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
4809 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
4810 }
4811
4812 // raygenShader
4813 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4814 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-04021",
4815 "vkCmdTraceRaysKHR: pRayGenShaderBindingTable->offset must be a multiple"
4816 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4817 }
4818 return skip;
4819}
4820
4821bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer,
4822 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
4823 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
4824 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
4825 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
4826 VkBuffer buffer, VkDeviceSize offset) const {
4827 bool skip = false;
4828 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4829 if (!raytracing_features || raytracing_features->rayTracingIndirectTraceRays == VK_FALSE) {
4830 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingIndirectTraceRays-03518",
4831 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectTraceRays "
4832 "feature must be enabled.");
4833 }
4834 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4835 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04038",
4836 "vkCmdTraceRaysIndirectKHR: The offset member of pCallableShaderBindingTable"
4837 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4838 }
4839 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
4840 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04040",
4841 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple"
4842 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
4843 }
4844 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
4845 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
4846 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be"
4847 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
4848 }
4849 // hitShader
4850 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4851 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04032",
4852 "vkCmdTraceRaysIndirectKHR: The offset member of pHitShaderBindingTable must be a multiple"
4853 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4854 }
4855 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
4856 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04034",
4857 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple"
4858 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
4859 }
4860 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
4861 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
4862 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be"
4863 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
4864 }
4865
4866 // missShader
4867 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4868 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04026",
4869 "vkCmdTraceRaysIndirectKHR: The offset member of pMissShaderBindingTable must be a multiple"
4870 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4871 }
4872 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
4873 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04028",
4874 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be a multiple"
4875 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
4876 }
4877 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
4878 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
4879 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be"
4880 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
4881 }
4882
4883 // raygenShader
4884 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4885 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-04021",
4886 "vkCmdTraceRaysIndirectKHR: pRayGenShaderBindingTable->offset must be a multiple"
4887 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4888 }
4889 return skip;
4890}
4891bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
4892 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
4893 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
4894 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
4895 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
4896 uint32_t width, uint32_t height, uint32_t depth) const {
4897 bool skip = false;
4898 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
4899 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
4900 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
4901 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
4902 }
4903 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
4904 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
4905 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
4906 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
4907 }
4908 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
4909 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
4910 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
4911 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
4912 }
4913
4914 // hitShader
4915 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
4916 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
4917 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
4918 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
4919 }
4920 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
4921 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
4922 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
4923 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
4924 }
4925 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
4926 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
4927 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
4928 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
4929 }
4930
4931 // missShader
4932 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
4933 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
4934 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
4935 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
4936 }
4937 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
4938 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
4939 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
4940 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
4941 }
4942 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
4943 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
4944 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
4945 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
4946 }
4947
4948 // raygenShader
4949 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
4950 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
4951 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
4952 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment .");
4953 }
4954 return skip;
4955}
4956
4957bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureIndirectKHR(
4958 VkCommandBuffer commandBuffer, const VkAccelerationStructureBuildGeometryInfoKHR *pInfo, VkBuffer indirectBuffer,
4959 VkDeviceSize indirectOffset, uint32_t indirectStride) const {
4960 bool skip = false;
4961 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4962 if (!raytracing_features || raytracing_features->rayTracingIndirectAccelerationStructureBuild == VK_FALSE) {
4963 skip |= LogError(
4964 device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-rayTracingIndirectAccelerationStructureBuild-03535",
4965 "vkCmdBuildAccelerationStructureIndirectKHR: The "
4966 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectAccelerationStructureBuild feature must be enabled.");
4967 }
4968 const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
4969 if (pNext_struct) {
4970 skip |=
4971 LogError(device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-pNext-03536",
4972 "vkCmdBuildAccelerationStructureIndirectKHR: The VkDeferredOperationInfoKHR structure must not be included in "
4973 "the pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
4974 }
4975 return false;
4976}
4977
4978bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
4979 VkDevice device, const VkAccelerationStructureVersionKHR *version) const {
4980 bool skip = false;
4981 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4982 if (!raytracing_features || !(raytracing_features->rayQuery || raytracing_features->rayTracing)) {
4983 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracing-03565",
4984 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
4985 }
4986 return skip;
4987}
4988
4989bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructureKHR(
4990 VkDevice device, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
4991 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
4992 bool skip = false;
4993 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4994 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4995 skip |= LogError(
4996 device, "VUID-vkBuildAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03439",
4997 "vkBuildAccelerationStructureKHR: The "
4998 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled .");
4999 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005000 return skip;
5001}