blob: e6bd69bd8f5f287b58887b9c4c23c1eba61c622e [file] [log] [blame]
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08001/* Copyright (c) 2015-2020 The Khronos Group Inc.
2 * Copyright (c) 2015-2020 Valve Corporation
3 * Copyright (c) 2015-2020 LunarG, Inc.
4 * Copyright (C) 2015-2020 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Mark Lobodzinskid4950072017-08-01 13:02:20 -060028static const int MaxParamCheckerStringLength = 256;
29
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070036bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050037 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060038 bool skip = false;
39
40 VkStringErrorFlags result = vk_string_validate(MaxParamCheckerStringLength, validateString);
41
42 if (result == VK_STRING_ERROR_NONE) {
43 return skip;
44 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070045 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
46 MaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060047 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070048 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
49 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060050 }
51 return skip;
52}
53
Jeff Bolz46c0ea02019-10-09 13:06:29 -050054bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060055 bool skip = false;
56 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
57 if (api_version_nopatch != effective_api_version) {
58 if (api_version_nopatch < VK_API_VERSION_1_0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070059 skip |= LogError(instance, kVUIDUndefined,
60 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
61 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
62 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060063 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070064 skip |= LogWarning(instance, kVUIDUndefined,
65 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
66 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
67 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060068 }
69 }
70 return skip;
71}
72
Jeff Bolz46c0ea02019-10-09 13:06:29 -050073bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060074 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060075 // Create and use a local instance extension object, as an actual instance has not been created yet
76 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
77 InstanceExtensions local_instance_extensions;
78 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
79
John Zulauf620755c2018-04-16 11:00:43 -060080 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060081 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
82 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060083 }
84
85 return skip;
86}
87
Tony-LunarG866843d2020-05-13 11:22:42 -060088bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
89 const VkValidationFeaturesEXT *validation_features) const {
90 bool skip = false;
91 bool debug_printf = false;
92 bool gpu_assisted = false;
93 bool reserve_slot = false;
94 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
95 switch (validation_features->pEnabledValidationFeatures[i]) {
96 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
97 gpu_assisted = true;
98 break;
99
100 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
101 debug_printf = true;
102 break;
103
104 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
105 reserve_slot = true;
106 break;
107
108 default:
109 break;
110 }
111 }
112 if (reserve_slot && !gpu_assisted) {
113 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
114 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
115 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
116 }
117 if (gpu_assisted && debug_printf) {
118 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
119 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
120 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
121 }
122
123 return skip;
124}
125
John Zulauf620755c2018-04-16 11:00:43 -0600126template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700127ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
128 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600129 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700130 ExtEnabled state =
131 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600132 return state;
133}
134
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700135bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500136 const VkAllocationCallbacks *pAllocator,
137 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700138 bool skip = false;
139 // Note: From the spec--
140 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
141 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
142 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700143 ? pCreateInfo->pApplicationInfo->apiVersion
144 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700145 skip |= validate_api_version(local_api_version, api_version);
146 skip |= validate_instance_extensions(pCreateInfo);
Tony-LunarG866843d2020-05-13 11:22:42 -0600147 const auto *validation_features = lvl_find_in_chain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
148 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
149
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700150 return skip;
151}
152
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700153void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700154 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
155 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700156 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
157 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700158 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700159 this->instance_extensions = instance_data->instance_extensions;
160}
161
162void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700163 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700164 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700165 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700166 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
167 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700168
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700169 // Parmeter validation also uses extension data
170 stateless_validation->device_extensions = this->device_extensions;
171
172 VkPhysicalDeviceProperties device_properties = {};
173 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600174 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700175 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
176
177 if (device_extensions.vk_nv_shading_rate_image) {
178 // Get the needed shading rate image limits
179 auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
180 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600181 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700182 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
183 }
184
185 if (device_extensions.vk_nv_mesh_shader) {
186 // Get the needed mesh shader limits
187 auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>();
188 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600189 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700190 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
191 }
192
Jason Macnak5c954952019-07-09 15:46:12 -0700193 if (device_extensions.vk_nv_ray_tracing) {
194 // Get the needed ray tracing limits
195 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>();
196 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
197 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500198 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
199 }
200
201 if (device_extensions.vk_khr_ray_tracing) {
202 // Get the needed ray tracing limits
203 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesKHR>();
204 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
205 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
206 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700207 }
208
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700209 if (device_extensions.vk_ext_transform_feedback) {
210 // Get the needed transform feedback limits
211 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
212 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
213 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
214 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
215 }
216
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800217 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
218
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700219 // Save app-enabled features in this device's validation object
220 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200221 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
222 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
223 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
224 if (features2) {
225 tmp_features2_state.features = features2->features;
226 } else if (pCreateInfo->pEnabledFeatures) {
227 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700228 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200229 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700230 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200231 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700232 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200233 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700234}
235
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700236bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500237 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600238 bool skip = false;
239
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200240 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
241 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
242 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600243 }
244
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200245 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
246 skip |=
247 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
248 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
249 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
250 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600251 }
252
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200253 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700254 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
255 bool negative_viewport =
256 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200257 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700258 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
259 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
260 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200261 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600262 }
263
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600264 {
265 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
266 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
267 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700268 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
269 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
270 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600271 }
272 }
273
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600274 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
275 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600276 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
277 if (features2) {
278 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700279 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700280 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
281 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600282 }
283 }
284
Locke77fad1c2019-04-16 13:09:03 -0600285 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
286 if (features2) {
287 if (!instance_extensions.vk_khr_get_physical_device_properties_2) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700288 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
289 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, "
290 "VK_KHR_get_physical_device_properties2 must be enabled when it creates an instance.");
Locke77fad1c2019-04-16 13:09:03 -0600291 }
292 }
293
Jeff Bolz165818a2020-05-08 11:19:03 -0500294 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
295 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
296 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
297 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
298 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
299 }
sourav parmara24fb7b2020-05-26 10:50:04 -0700300 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(pCreateInfo->pNext);
301 if (raytracing_features && raytracing_features->rayTracingShaderGroupHandleCaptureReplayMixed &&
302 !raytracing_features->rayTracingShaderGroupHandleCaptureReplay) {
303 skip |= LogError(device, "VUID-VkPhysicalDeviceRayTracingFeaturesKHR-rayTracingShaderGroupHandleCaptureReplayMixed-03348",
304 "If rayTracingShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingShaderGroupHandleCaptureReplay "
305 "must also be VK_TRUE.");
306 }
Locke77fad1c2019-04-16 13:09:03 -0600307 auto vertex_attribute_divisor_features =
308 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
309 if (vertex_attribute_divisor_features) {
310 bool extension_found = false;
311 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
312 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
313 VK_MAX_EXTENSION_NAME_SIZE)) {
314 extension_found = true;
315 break;
316 }
317 }
318 if (!extension_found) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700319 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
320 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
321 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600322 }
323 }
324
Tony-LunarG28017bc2020-01-23 14:40:25 -0700325 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
326 if (vulkan_11_features) {
327 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
328 while (current) {
329 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
330 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
331 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
332 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
333 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
334 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700335 skip |= LogError(
336 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700337 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
338 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
339 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
340 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
341 break;
342 }
343 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
344 }
345 }
346
347 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
348 if (vulkan_12_features) {
349 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
350 while (current) {
351 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
352 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
353 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
354 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
355 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
356 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
357 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
358 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
359 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
360 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
361 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
362 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
363 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700364 skip |= LogError(
365 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700366 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
367 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
368 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
369 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
370 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
371 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
372 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
373 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
374 break;
375 }
376 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
377 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700378 // Check features are enabled if matching extension is passed in as well
379 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
380 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
381 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
382 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
383 skip |= LogError(
384 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
385 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
386 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
387 }
388 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
389 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
390 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
391 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
392 "is not VK_TRUE.",
393 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
394 }
395 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
396 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
397 skip |= LogError(
398 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
399 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
400 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
401 }
402 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
403 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
404 skip |= LogError(
405 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
406 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
407 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
408 }
409 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
410 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
411 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
412 skip |=
413 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
414 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
415 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
416 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
417 }
418 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700419 }
420
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600421 // Validate pCreateInfo->pQueueCreateInfos
422 if (pCreateInfo->pQueueCreateInfos) {
423 std::unordered_set<uint32_t> set;
424
425 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700426 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
427 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600428 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700429 skip |=
430 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
431 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
432 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
433 "index value.",
434 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600435 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700436 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
437 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
438 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
439 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600440 } else {
441 set.insert(requested_queue_family);
442 }
443
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700444 if (queue_create_info.pQueuePriorities != nullptr) {
445 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
446 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600447 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700448 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
449 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
450 "] (=%f) is not between 0 and 1 (inclusive).",
451 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600452 }
453 }
454 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700455
456 // Need to know if protectedMemory feature is passed in preCall to creating the device
457 VkBool32 protectedMemory = VK_FALSE;
458 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
459 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
460 if (protected_features) {
461 protectedMemory = protected_features->protectedMemory;
462 } else if (vulkan_11_features) {
463 protectedMemory = vulkan_11_features->protectedMemory;
464 }
465 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) {
466 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
467 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
468 "protectedMemory feature being set as well.");
469 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600470 }
471 }
472
sfricke-samsung30a57412020-05-15 21:14:54 -0700473 // feature dependencies for VK_KHR_variable_pointers
474 const auto *variable_pointers_features = lvl_find_in_chain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
475 VkBool32 variablePointers = VK_FALSE;
476 VkBool32 variablePointersStorageBuffer = VK_FALSE;
477 if (vulkan_11_features) {
478 variablePointers = vulkan_11_features->variablePointers;
479 variablePointersStorageBuffer = vulkan_11_features->variablePointersStorageBuffer;
480 } else if (variable_pointers_features) {
481 variablePointers = variable_pointers_features->variablePointers;
482 variablePointersStorageBuffer = variable_pointers_features->variablePointersStorageBuffer;
483 }
484 if ((variablePointers == VK_TRUE) && (variablePointersStorageBuffer == VK_FALSE)) {
485 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
486 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
487 }
488
sfricke-samsungfd76c342020-05-29 23:13:43 -0700489 // feature dependencies for VK_KHR_multiview
490 const auto *multiview_features = lvl_find_in_chain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
491 VkBool32 multiview = VK_FALSE;
492 VkBool32 multiviewGeometryShader = VK_FALSE;
493 VkBool32 multiviewTessellationShader = VK_FALSE;
494 if (vulkan_11_features) {
495 multiview = vulkan_11_features->multiview;
496 multiviewGeometryShader = vulkan_11_features->multiviewGeometryShader;
497 multiviewTessellationShader = vulkan_11_features->multiviewTessellationShader;
498 } else if (multiview_features) {
499 multiview = multiview_features->multiview;
500 multiviewGeometryShader = multiview_features->multiviewGeometryShader;
501 multiviewTessellationShader = multiview_features->multiviewTessellationShader;
502 }
503 if ((multiview == VK_FALSE) && (multiviewGeometryShader == VK_TRUE)) {
504 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
505 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
506 }
507 if ((multiview == VK_FALSE) && (multiviewTessellationShader == VK_TRUE)) {
508 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
509 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
510 }
511
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600512 return skip;
513}
514
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500515bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700516 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700517 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
518 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
519 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600520 }
521
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700522 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600523}
524
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700525bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500526 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100527 bool skip = false;
528
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600529 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700530 skip |=
531 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600532
533 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
534 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
535 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
536 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700537 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
538 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
539 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600540 }
541
542 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
543 // queueFamilyIndexCount uint32_t values
544 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700545 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
546 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
547 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
548 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600549 }
550 }
551
552 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
553 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
554 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
555 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700556 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
557 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
558 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600559 }
560 }
561
562 return skip;
563}
564
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700565bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500566 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600567 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600568
569 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600570 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
571 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
572 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
573 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700574 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
575 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
576 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600577 }
578
579 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
580 // queueFamilyIndexCount uint32_t values
581 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700582 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
583 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
584 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
585 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600586 }
587 }
588
Dave Houlton413a6782018-05-22 13:01:54 -0600589 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700590 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600591 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700592 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600593 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700594 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600595
Dave Houlton413a6782018-05-22 13:01:54 -0600596 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700597 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600598 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700599 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600600
Dave Houlton130c0212018-01-29 13:39:56 -0700601 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700602 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
603 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700604 skip |= LogError(
605 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600606 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
607 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700608 }
609
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600610 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100611 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
612 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700613 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
614 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
615 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600616 }
617
618 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100619 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
620 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700621 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
622 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
623 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
624 ") are not equal.",
625 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100626 }
627
628 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700629 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
630 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
631 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
632 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100633 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600634 }
635
636 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700637 skip |= LogError(
638 device, "VUID-VkImageCreateInfo-imageType-00957",
639 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600640 }
641 }
642
Dave Houlton130c0212018-01-29 13:39:56 -0700643 // 3D image may have only 1 layer
644 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700645 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
646 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700647 }
648
649 // If multi-sample, validate type, usage, tiling and mip levels.
650 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
651 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600652 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700653 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
654 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700655 }
656
657 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
658 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
659 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
660 // At least one of the legal attachment bits must be set
661 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700662 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
663 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700664 }
665 // No flags other than the legal attachment bits may be set
666 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
667 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700668 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
669 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700670 }
671 }
672
Jeff Bolzef40fec2018-09-01 22:04:34 -0500673 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600674 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500675 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600676 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
677 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500678 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600679 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700680 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
681 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
682 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600683 }
684
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600685 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700686 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
687 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
688 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600689 }
690
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700691 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700692 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
693 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
694 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100695 }
696
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600697 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
698 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
699 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
700 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700701 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
702 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
703 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600704 }
705
706 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
707 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
708 // Linear tiling is unsupported
709 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700710 skip |= LogError(device, kVUID_PVError_InvalidUsage,
711 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
712 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600713 }
714
715 // Sparse 1D image isn't valid
716 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700717 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
718 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600719 }
720
721 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700722 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700723 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
724 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
725 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600726 }
727
728 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700729 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700730 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
731 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
732 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600733 }
734
735 // Multi-sample 2D image when device doesn't support it
736 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700737 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600738 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700739 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
740 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
741 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700742 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600743 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700744 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
745 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
746 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700747 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600748 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700749 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
750 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
751 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700752 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600753 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700754 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
755 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
756 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600757 }
758 }
759 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500760
Jeff Bolz9af91c52018-09-01 21:53:57 -0500761 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
762 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700763 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
764 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
765 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500766 }
767 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700768 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
769 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
770 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500771 }
772 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700773 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
774 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
775 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500776 }
777 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500778
779 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600780 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700781 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
782 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
783 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500784 }
785
Dave Houlton142c4cb2018-10-17 15:04:41 -0600786 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700787 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
788 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
789 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
790 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500791 }
792
Dave Houlton142c4cb2018-10-17 15:04:41 -0600793 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700794 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
795 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
796 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
797 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500798 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600799 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700800 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
801 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
802 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
803 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500804 }
805 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500806
sfricke-samsung8f658d42020-05-03 20:12:24 -0700807 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
808 (FormatHasDepth(pCreateInfo->format) == false)) {
809 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
810 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
811 "format must be a depth or depth/stencil format.");
812 }
813
Andrew Fobel3abeb992020-01-20 16:33:22 -0500814 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
815 if (image_stencil_struct != nullptr) {
816 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
817 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
818 // No flags other than the legal attachment bits may be set
819 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
820 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700821 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
822 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
823 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
824 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500825 }
826 }
827
828 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
829 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
830 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
831 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700832 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
833 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
834 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
835 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500836 }
837
838 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
839 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700840 LogError(device, "VUID-VkImageCreateInfo-format-02537",
841 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
842 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
843 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500844 }
845 }
846
847 if (!physical_device_features.shaderStorageImageMultisample &&
848 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
849 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
850 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700851 LogError(device, "VUID-VkImageCreateInfo-format-02538",
852 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
853 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
854 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500855 }
856
857 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
858 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700859 skip |= LogError(
860 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500861 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
862 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
863 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
864 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
865 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700866 skip |= LogError(
867 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500868 "vkCreateImage(): Depth-stencil image in which usage does not include "
869 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
870 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
871 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
872 }
873
874 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
875 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700876 skip |= LogError(
877 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500878 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
879 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
880 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
881 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
882 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700883 skip |= LogError(
884 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500885 "vkCreateImage(): Depth-stencil image in which usage does not include "
886 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
887 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
888 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
889 }
890 }
891 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700892
893 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
894 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
895 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
896 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
897 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
898 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700899
900 if (device_extensions.vk_ext_image_drm_format_modifier) {
901 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
902 const auto drm_format_mod_explict =
903 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
904 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
905 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
906 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
907 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
908 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
909 "either VkImageDrmFormatModifierListCreateInfoEXT or "
910 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
911 }
912 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
913 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
914 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
915 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
916 "in the pNext chain");
917 }
918 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +0200919
920 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
921 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
922 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
923 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
924 "imageType must be VK_IMAGE_TYPE_2D.");
925 }
926 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
927 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
928 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
929 "samples must be VK_SAMPLE_COUNT_1_BIT.");
930 }
931 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
932 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
933 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
934 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
935 }
936 }
937 if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
938 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
939 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
940 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
941 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
942 }
943 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
944 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
945 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
946 "imageType must be VK_IMAGE_TYPE_2D.");
947 }
948 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
949 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
950 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
951 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
952 }
953 if (pCreateInfo->mipLevels != 1) {
954 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
955 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
956 pCreateInfo->mipLevels);
957 }
958 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600959 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500960
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600961 return skip;
962}
963
Jeff Bolz99e3f632020-03-24 22:59:22 -0500964bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
965 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
966 bool skip = false;
967
968 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700969 // Validate feature set if using CUBE_ARRAY
970 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
971 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
972 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
973 "enabling the imageCubeArray feature.");
974 }
975
Jeff Bolz99e3f632020-03-24 22:59:22 -0500976 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
977 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
978 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -0700979 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -0500980 pCreateInfo->subresourceRange.layerCount);
981 }
982 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700983 skip |= LogError(
984 device, "VUID-VkImageViewCreateInfo-viewType-02961",
985 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
986 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -0500987 }
988 }
989 }
990 return skip;
991}
992
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600993bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700994 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100995 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100996
997 // Note: for numerical correctness
998 // - float comparisons should expect NaN (comparison always false).
999 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1000
1001 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001002 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001003 if (v1_f <= 0.0f) return true;
1004
1005 float intpart;
1006 const float fract = modff(v1_f, &intpart);
1007
1008 assert(std::numeric_limits<float>::radix == 2);
1009 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1010 if (intpart >= u32_max_plus1) return false;
1011
1012 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
1013 if (v1_u32 < v2_u32)
1014 return true;
1015 else if (v1_u32 == v2_u32 && fract == 0.0f)
1016 return true;
1017 else
1018 return false;
1019 };
1020
1021 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1022 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1023 return (v1_f <= v2_f);
1024 };
1025
1026 // width
1027 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001028 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001029
1030 if (!(viewport.width > 0.0f)) {
1031 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001032 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1033 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001034 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1035 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001036 skip |= LogError(object, "VUID-VkViewport-width-01771",
1037 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1038 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001039 } 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 -07001040 skip |= LogWarning(object, kVUID_PVError_NONE,
1041 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
1042 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
1043 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001044 }
1045
1046 // height
1047 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001048 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001049 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001050
1051 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1052 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001053 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1054 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001055 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1056 height_healthy = false;
1057
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001058 skip |= LogError(object, "VUID-VkViewport-height-01773",
1059 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1060 ").",
1061 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001062 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
1063 height_healthy = false;
1064
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001065 skip |= LogWarning(
1066 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +01001067 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001068 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001069 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001070 }
1071
1072 // x
1073 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001074 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001075 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001076 skip |= LogError(object, "VUID-VkViewport-x-01774",
1077 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1078 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001079 }
1080
1081 // x + width
1082 if (x_healthy && width_healthy) {
1083 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001084 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001085 skip |= LogError(
1086 object, "VUID-VkViewport-x-01232",
1087 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1088 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1089 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001090 }
1091 }
1092
1093 // y
1094 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001095 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001096 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001097 skip |= LogError(object, "VUID-VkViewport-y-01775",
1098 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1099 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001100 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001101 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001102 skip |= LogError(object, "VUID-VkViewport-y-01776",
1103 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1104 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001105 }
1106
1107 // y + height
1108 if (y_healthy && height_healthy) {
1109 const float boundary = viewport.y + viewport.height;
1110
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001111 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001112 skip |= LogError(object, "VUID-VkViewport-y-01233",
1113 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1114 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1115 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001116 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001117 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001118 LogError(object, "VUID-VkViewport-y-01777",
1119 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1120 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1121 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001122 }
1123 }
1124
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001125 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001126 // minDepth
1127 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001128 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001129
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001130 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1131 "[0.0, 1.0] range.",
1132 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001133 }
1134
1135 // maxDepth
1136 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001137 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001138
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001139 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1140 "[0.0, 1.0] range.",
1141 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001142 }
1143 }
1144
1145 return skip;
1146}
1147
Dave Houlton142c4cb2018-10-17 15:04:41 -06001148struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001149 VkShadingRatePaletteEntryNV shadingRate;
1150 uint32_t width;
1151 uint32_t height;
1152};
1153
1154// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -06001155static SampleOrderInfo sampleOrderInfos[] = {
1156 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1157 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1158 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1159 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1160 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1161 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001162};
1163
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001164bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001165 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001166
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001167 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001168 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001169 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001170 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001171 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001172 break;
1173 }
1174 }
1175
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001176 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001177 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1178 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1179 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001180 return skip;
1181 }
1182
Dave Houlton142c4cb2018-10-17 15:04:41 -06001183 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001184 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001185 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1186 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1187 ") must "
1188 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1189 "is set in framebufferNoAttachmentsSampleCounts.",
1190 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001191 }
1192
Jeff Bolz9af91c52018-09-01 21:53:57 -05001193 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001194 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1195 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1196 ") must "
1197 "be equal to the product of sampleCount (=%" PRIu32
1198 "), the fragment width for shadingRate "
1199 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1200 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001201 }
1202
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001203 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001204 skip |= LogError(
1205 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001206 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1207 ") must "
1208 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001209 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001210 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001211
1212 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001213 // the first width*height*sampleCount bits to all be set. Note: There is no
1214 // guarantee that 64 bits is enough, but practically it's unlikely for an
1215 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001216 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001217 uint64_t sampleLocationsMask = 0;
1218 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1219 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1220 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001221 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1222 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001223 }
1224 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001225 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1226 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001227 }
1228 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001229 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1230 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001231 }
1232 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1233 sampleLocationsMask |= 1ULL << idx;
1234 }
1235
1236 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1237 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001238 skip |= LogError(
1239 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001240 "The array pSampleLocations must contain exactly one entry for "
1241 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001242 }
1243
1244 return skip;
1245}
1246
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001247bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1248 uint32_t createInfoCount,
1249 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1250 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001251 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001252 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001253
1254 if (pCreateInfos != nullptr) {
1255 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001256 bool has_dynamic_viewport = false;
1257 bool has_dynamic_scissor = false;
1258 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001259 bool has_dynamic_depth_bias = false;
1260 bool has_dynamic_blend_constant = false;
1261 bool has_dynamic_depth_bounds = false;
1262 bool has_dynamic_stencil_compare = false;
1263 bool has_dynamic_stencil_write = false;
1264 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001265 bool has_dynamic_viewport_w_scaling_nv = false;
1266 bool has_dynamic_discard_rectangle_ext = false;
1267 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001268 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001269 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001270 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001271 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001272 if (pCreateInfos[i].pDynamicState != nullptr) {
1273 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1274 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1275 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001276 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1277 if (has_dynamic_viewport == true) {
1278 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1279 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1280 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1281 i);
1282 }
1283 has_dynamic_viewport = true;
1284 }
1285 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1286 if (has_dynamic_scissor == true) {
1287 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1288 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1289 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1290 i);
1291 }
1292 has_dynamic_scissor = true;
1293 }
1294 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1295 if (has_dynamic_line_width == true) {
1296 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1297 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1298 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1299 i);
1300 }
1301 has_dynamic_line_width = true;
1302 }
1303 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1304 if (has_dynamic_depth_bias == true) {
1305 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1306 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1307 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1308 i);
1309 }
1310 has_dynamic_depth_bias = true;
1311 }
1312 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1313 if (has_dynamic_blend_constant == true) {
1314 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1315 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1316 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1317 i);
1318 }
1319 has_dynamic_blend_constant = true;
1320 }
1321 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1322 if (has_dynamic_depth_bounds == true) {
1323 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1324 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1325 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1326 i);
1327 }
1328 has_dynamic_depth_bounds = true;
1329 }
1330 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1331 if (has_dynamic_stencil_compare == true) {
1332 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1333 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1334 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1335 i);
1336 }
1337 has_dynamic_stencil_compare = true;
1338 }
1339 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1340 if (has_dynamic_stencil_write == true) {
1341 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1342 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1343 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1344 i);
1345 }
1346 has_dynamic_stencil_write = true;
1347 }
1348 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1349 if (has_dynamic_stencil_reference == true) {
1350 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1351 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1352 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1353 i);
1354 }
1355 has_dynamic_stencil_reference = true;
1356 }
1357 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1358 if (has_dynamic_viewport_w_scaling_nv == true) {
1359 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1360 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1361 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1362 i);
1363 }
1364 has_dynamic_viewport_w_scaling_nv = true;
1365 }
1366 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1367 if (has_dynamic_discard_rectangle_ext == true) {
1368 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1369 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1370 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1371 i);
1372 }
1373 has_dynamic_discard_rectangle_ext = true;
1374 }
1375 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1376 if (has_dynamic_sample_locations_ext == true) {
1377 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1378 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1379 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1380 i);
1381 }
1382 has_dynamic_sample_locations_ext = true;
1383 }
1384 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1385 if (has_dynamic_exclusive_scissor_nv == true) {
1386 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1387 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1388 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1389 i);
1390 }
1391 has_dynamic_exclusive_scissor_nv = true;
1392 }
1393 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1394 if (has_dynamic_shading_rate_palette_nv == true) {
1395 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1396 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1397 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1398 i);
1399 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001400 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001401 }
1402 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1403 if (has_dynamic_viewport_course_sample_order_nv == true) {
1404 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1405 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1406 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1407 i);
1408 }
1409 has_dynamic_viewport_course_sample_order_nv = true;
1410 }
1411 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1412 if (has_dynamic_line_stipple == true) {
1413 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1414 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1415 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1416 i);
1417 }
1418 has_dynamic_line_stipple = true;
1419 }
Petr Kraus299ba622017-11-24 03:09:03 +01001420 }
1421 }
1422
Peter Chen85366392019-05-14 15:20:11 -04001423 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1424 if ((feedback_struct != nullptr) &&
1425 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001426 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1427 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1428 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1429 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1430 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001431 }
1432
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001433 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001434
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001435 // Collect active stages and other information
1436 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001437 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001438 bool has_eval = false;
1439 bool has_control = false;
1440 if (pCreateInfos[i].pStages != nullptr) {
1441 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1442 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1443
1444 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1445 has_control = true;
1446 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1447 has_eval = true;
1448 }
1449
1450 skip |= validate_string(
1451 "vkCreateGraphicsPipelines",
1452 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1453 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1454 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001455 }
1456
1457 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1458 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1459 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1460 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1461 pCreateInfos[i].pTessellationState,
1462 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1463 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1464
1465 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1466 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1467
1468 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1469 "VkPipelineTessellationDomainOriginStateCreateInfo",
1470 pCreateInfos[i].pTessellationState->pNext,
1471 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1472 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001473 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1474 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001475
1476 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1477 pCreateInfos[i].pTessellationState->flags,
1478 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1479 }
1480
1481 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1482 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1483 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1484 pCreateInfos[i].pInputAssemblyState,
1485 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1486 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1487
1488 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1489 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001490 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001491
1492 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1493 pCreateInfos[i].pInputAssemblyState->flags,
1494 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1495
1496 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1497 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1498 pCreateInfos[i].pInputAssemblyState->topology,
1499 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1500
1501 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1502 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1503 }
1504
1505 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001506 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001507
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001508 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001509 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1510 "vkCreateGraphicsPipelines: pararameter "
1511 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1512 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001513 }
1514
1515 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1516 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1517 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1518 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1519 pCreateInfos[i].pVertexInputState->pNext, 1,
1520 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001521 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1522 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001523 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1524 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001525 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001526 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1527 skip |=
1528 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1529 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1530 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1531 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1532 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1533
1534 skip |= validate_array(
1535 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1536 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1537 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1538 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1539
1540 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1541 for (uint32_t vertexBindingDescriptionIndex = 0;
1542 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1543 ++vertexBindingDescriptionIndex) {
1544 skip |= validate_ranged_enum(
1545 "vkCreateGraphicsPipelines",
1546 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1547 AllVkVertexInputRateEnums,
1548 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1549 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1550 }
1551 }
1552
1553 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1554 for (uint32_t vertexAttributeDescriptionIndex = 0;
1555 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1556 ++vertexAttributeDescriptionIndex) {
1557 skip |= validate_ranged_enum(
1558 "vkCreateGraphicsPipelines",
1559 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1560 AllVkFormatEnums,
1561 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1562 "VUID-VkVertexInputAttributeDescription-format-parameter");
1563 }
1564 }
1565
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001566 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001567 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1568 "vkCreateGraphicsPipelines: pararameter "
1569 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1570 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1571 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001572 }
1573
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001574 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001575 skip |=
1576 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1577 "vkCreateGraphicsPipelines: pararameter "
1578 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1579 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1580 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001581 }
1582
1583 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001584 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1585 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001586 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1587 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001588 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1589 "vkCreateGraphicsPipelines: parameter "
1590 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1591 "(%" PRIu32 ") is not distinct.",
1592 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001593 }
1594 vertex_bindings.insert(vertex_bind_desc.binding);
1595
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001596 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001597 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1598 "vkCreateGraphicsPipelines: parameter "
1599 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1600 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1601 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001602 }
1603
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001604 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001605 skip |=
1606 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1607 "vkCreateGraphicsPipelines: parameter "
1608 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1609 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1610 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001611 }
1612 }
1613
Peter Kohautc7d9d392018-07-15 00:34:07 +02001614 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001615 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1616 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001617 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1618 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001619 skip |= LogError(
1620 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001621 "vkCreateGraphicsPipelines: parameter "
1622 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1623 i, d, vertex_attrib_desc.location);
1624 }
1625 attribute_locations.insert(vertex_attrib_desc.location);
1626
1627 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1628 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001629 skip |= LogError(
1630 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001631 "vkCreateGraphicsPipelines: parameter "
1632 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1633 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1634 i, d, vertex_attrib_desc.binding, i);
1635 }
1636
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001637 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001638 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1639 "vkCreateGraphicsPipelines: parameter "
1640 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1641 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1642 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001643 }
1644
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001645 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001646 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1647 "vkCreateGraphicsPipelines: parameter "
1648 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1649 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1650 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001651 }
1652
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001653 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001654 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1655 "vkCreateGraphicsPipelines: parameter "
1656 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1657 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1658 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001659 }
1660 }
1661 }
1662
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001663 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1664 if (has_control && has_eval) {
1665 if (pCreateInfos[i].pTessellationState == nullptr) {
1666 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1667 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1668 "shader stage and a tessellation evaluation shader stage, "
1669 "pCreateInfos[%d].pTessellationState must not be NULL.",
1670 i, i);
1671 } else {
1672 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1673 skip |= validate_struct_pnext(
1674 "vkCreateGraphicsPipelines",
1675 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1676 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1677 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1678 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001679
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001680 skip |= validate_reserved_flags(
1681 "vkCreateGraphicsPipelines",
1682 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1683 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001684
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001685 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1686 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1687 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1688 "vkCreateGraphicsPipelines: invalid parameter "
1689 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1690 "should be >0 and <=%u.",
1691 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1692 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001693 }
1694 }
1695 }
1696
1697 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1698 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1699 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1700 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001701 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1702 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1703 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1704 "].pViewportState (=NULL) is not a valid pointer.",
1705 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001706 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001707 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1708
1709 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001710 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1711 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1712 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1713 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001714 }
1715
Petr Krausa6103552017-11-16 21:21:58 +01001716 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1717 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001718 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1719 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001720 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1721 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001722 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001723 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001724 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001725 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001726 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001727 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1728 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001729 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001730 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1731 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001732
1733 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001734 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001735 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001736 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001737
Dave Houlton142c4cb2018-10-17 15:04:41 -06001738 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1739 pCreateInfos[i].pViewportState->pNext);
1740 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1741 pCreateInfos[i].pViewportState->pNext);
1742 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1743 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001744 const auto vp_swizzle_struct =
1745 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001746 const auto vp_w_scaling_struct =
1747 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001748
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001749 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001750 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001751 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1752 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1753 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1754 ") is not 1.",
1755 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001756 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001757
Petr Krausa6103552017-11-16 21:21:58 +01001758 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001759 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1760 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1761 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1762 ") is not 1.",
1763 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001764 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001765
Dave Houlton142c4cb2018-10-17 15:04:41 -06001766 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1767 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001768 skip |= LogError(
1769 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1770 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1771 "disabled, but pCreateInfos[%" PRIu32
1772 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1773 ") is not 1.",
1774 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001775 }
1776
Jeff Bolz9af91c52018-09-01 21:53:57 -05001777 if (shading_rate_image_struct &&
1778 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001779 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
1780 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1781 "disabled, but pCreateInfos[%" PRIu32
1782 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
1783 ") is neither 0 nor 1.",
1784 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001785 }
1786
Petr Krausa6103552017-11-16 21:21:58 +01001787 } else { // multiViewport enabled
1788 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001789 skip |= LogError(
1790 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001791 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001792 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001793 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
1794 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1795 "].pViewportState->viewportCount (=%" PRIu32
1796 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1797 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001798 }
Petr Krausa6103552017-11-16 21:21:58 +01001799
1800 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001801 skip |= LogError(
1802 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001803 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001804 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001805 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
1806 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1807 "].pViewportState->scissorCount (=%" PRIu32
1808 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1809 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001810 }
1811 }
1812
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001813 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001814 skip |=
1815 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1816 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1817 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1818 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001819 }
1820
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001821 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001822 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1823 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1824 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1825 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1826 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001827 }
1828
Petr Krausa6103552017-11-16 21:21:58 +01001829 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001830 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
1831 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1832 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1833 "].pViewportState->viewportCount (=%" PRIu32 ").",
1834 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001835 }
1836
Dave Houlton142c4cb2018-10-17 15:04:41 -06001837 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001838 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001839 skip |=
1840 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1841 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1842 ") must be zero or identical to pCreateInfos[%" PRIu32
1843 "].pViewportState->viewportCount (=%" PRIu32 ").",
1844 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001845 }
1846
Dave Houlton142c4cb2018-10-17 15:04:41 -06001847 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001848 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001849 skip |= LogError(
1850 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001851 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1852 "] "
1853 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1854 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1855 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001856 }
1857
Petr Krausa6103552017-11-16 21:21:58 +01001858 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001859 skip |= LogError(
1860 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001861 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1862 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001863 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1864 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001865 }
1866
1867 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001868 skip |= LogError(
1869 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001870 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1871 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001872 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1873 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001874 }
1875
Jeff Bolz3e71f782018-08-29 23:15:45 -05001876 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001877 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1878 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1879 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06001880 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001881 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1882 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1883 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1884 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001885 }
1886
Jeff Bolz9af91c52018-09-01 21:53:57 -05001887 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001888 shading_rate_image_struct->viewportCount > 0 &&
1889 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001890 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06001891 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001892 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001893 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1894 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001895 i, i);
1896 }
1897
Chris Mayer328d8212018-12-11 14:16:18 +01001898 if (vp_swizzle_struct) {
1899 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001900 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
1901 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
1902 " does "
1903 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
1904 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01001905 }
1906 }
1907
Petr Krausb3fcdb42018-01-09 22:09:09 +01001908 // validate the VkViewports
1909 if (!has_dynamic_viewport && viewport_state.pViewports) {
1910 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
1911 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001912 const char *fn_name = "vkCreateGraphicsPipelines";
1913 skip |= manual_PreCallValidateViewport(viewport, fn_name,
1914 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
1915 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001916 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01001917 }
1918 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001919
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001920 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001921 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1922 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1923 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
1924 "VK_NV_clip_space_w_scaling extension is not enabled.",
1925 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001926 }
1927
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001928 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001929 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1930 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1931 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
1932 "VK_EXT_discard_rectangles extension is not enabled.",
1933 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001934 }
1935
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001936 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001937 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1938 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1939 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
1940 "VK_EXT_sample_locations extension is not enabled.",
1941 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001942 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001943
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001944 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001945 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1946 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1947 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
1948 "VK_NV_scissor_exclusive extension is not enabled.",
1949 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001950 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001951
1952 if (coarse_sample_order_struct &&
1953 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
1954 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001955 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
1956 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1957 "] "
1958 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
1959 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
1960 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001961 }
1962
1963 if (coarse_sample_order_struct) {
1964 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001965 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001966 }
1967 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001968
1969 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
1970 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001971 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
1972 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1973 "] "
1974 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
1975 ") "
1976 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
1977 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001978 }
1979 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001980 skip |= LogError(
1981 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001982 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1983 "] "
1984 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
1985 i);
1986 }
1987 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001988 }
1989
1990 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001991 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
1992 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
1993 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
1994 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001995 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07001996 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
1997 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
1998 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07001999 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002000 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002001 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002002 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002003 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002004 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002005 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002006 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2007 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002008
2009 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002010 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002011 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002012 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002013
2014 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002015 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002016 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2017 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2018
2019 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002020 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002021 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2022 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002023 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002024 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002025
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002026 skip |= validate_flags(
2027 "vkCreateGraphicsPipelines",
2028 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2029 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002030 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002031
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002032 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002033 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002034 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2035 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2036
2037 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002038 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002039 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2040 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2041
2042 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002043 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2044 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2045 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2046 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002047 }
John Zulauf7acac592017-11-06 11:15:53 -07002048 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002049 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002050 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2051 "vkCreateGraphicsPipelines(): parameter "
2052 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2053 i);
John Zulauf7acac592017-11-06 11:15:53 -07002054 }
2055 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2056 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2057 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002058 skip |= LogError(
2059 device,
2060
Dave Houlton413a6782018-05-22 13:01:54 -06002061 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002062 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002063 }
2064 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002065
2066 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
2067 pCreateInfos[i].pRasterizationState->pNext);
2068
2069 if (line_state) {
2070 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2071 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2072 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2073 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002074 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2075 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2076 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2077 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002078 }
2079 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2080 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002081 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2082 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2083 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2084 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002085 }
2086 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2087 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002088 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2089 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2090 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2091 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002092 }
2093 }
2094 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2095 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2096 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002097 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2098 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2099 "range [1,256].",
2100 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002101 }
2102 }
2103 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002104 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002105 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2106 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002107 skip |=
2108 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2109 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2110 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2111 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002112 }
2113 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2114 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002115 skip |=
2116 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2117 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2118 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2119 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002120 }
2121 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2122 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002123 skip |=
2124 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2125 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2126 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2127 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002128 }
2129 if (line_state->stippledLineEnable) {
2130 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2131 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002132 skip |=
2133 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2134 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2135 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2136 "stippledRectangularLines feature.",
2137 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002138 }
2139 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2140 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002141 skip |=
2142 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2143 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2144 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2145 "stippledBresenhamLines feature.",
2146 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002147 }
2148 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2149 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002150 skip |=
2151 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2152 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2153 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2154 "stippledSmoothLines feature.",
2155 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002156 }
2157 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2158 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002159 skip |=
2160 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2161 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2162 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2163 "stippledRectangularLines and strictLines features.",
2164 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002165 }
2166 }
2167 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002168 }
2169
Petr Krause91f7a12017-12-14 20:57:36 +01002170 bool uses_color_attachment = false;
2171 bool uses_depthstencil_attachment = false;
2172 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002173 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002174 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2175 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002176 const auto &subpasses_uses = subpasses_uses_it->second;
2177 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
2178 uses_color_attachment = true;
2179 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
2180 uses_depthstencil_attachment = true;
2181 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002182 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002183 }
2184
2185 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002186 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002187 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002188 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002189 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002190 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002191
2192 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002193 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002194 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002195 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002196
2197 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002198 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002199 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2200 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2201
2202 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002203 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002204 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2205 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2206
2207 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002208 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002209 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2210 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002211 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002212
2213 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002214 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002215 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2216 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2217
2218 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002219 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002220 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2221 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2222
2223 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002224 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002225 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2226 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002227 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002228
2229 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002230 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002231 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2232 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002233 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002234
2235 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002236 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002237 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2238 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002239 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002240
2241 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002242 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002243 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2244 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002245 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002246
2247 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002248 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002249 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2250 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002251 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002252
2253 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002254 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002255 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2256 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002257 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002258
2259 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002260 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002261 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2262 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002263 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002264
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].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2268 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002269 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002270
2271 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002272 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2273 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2274 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2275 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002276 }
2277 }
2278
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002279 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2280 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2281
Petr Krause91f7a12017-12-14 20:57:36 +01002282 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002283 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2284 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2285 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2286 pCreateInfos[i].pColorBlendState,
2287 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2288 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2289
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002290 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002291 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002292 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2293 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2294 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002295 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002296 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2297 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002298
2299 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002300 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002301 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002302 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002303
2304 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002305 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002306 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2307 pCreateInfos[i].pColorBlendState->logicOpEnable);
2308
2309 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002310 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002311 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2312 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002313 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002314 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002315
2316 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2317 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2318 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002319 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002320 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2321 ParameterName::IndexVector{i, attachmentIndex}),
2322 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2323
2324 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002325 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002326 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2327 ParameterName::IndexVector{i, attachmentIndex}),
2328 "VkBlendFactor", AllVkBlendFactorEnums,
2329 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002330 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002331
2332 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002333 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002334 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2335 ParameterName::IndexVector{i, attachmentIndex}),
2336 "VkBlendFactor", AllVkBlendFactorEnums,
2337 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002338 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002339
2340 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002341 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002342 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2343 ParameterName::IndexVector{i, attachmentIndex}),
2344 "VkBlendOp", AllVkBlendOpEnums,
2345 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002346 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002347
2348 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002349 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002350 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2351 ParameterName::IndexVector{i, attachmentIndex}),
2352 "VkBlendFactor", AllVkBlendFactorEnums,
2353 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002354 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002355
2356 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002357 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002358 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2359 ParameterName::IndexVector{i, attachmentIndex}),
2360 "VkBlendFactor", AllVkBlendFactorEnums,
2361 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002362 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002363
2364 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002365 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002366 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2367 ParameterName::IndexVector{i, attachmentIndex}),
2368 "VkBlendOp", AllVkBlendOpEnums,
2369 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002370 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002371
2372 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002373 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002374 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2375 ParameterName::IndexVector{i, attachmentIndex}),
2376 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2377 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002378 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002379 }
2380 }
2381
2382 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002383 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2384 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2385 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2386 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002387 }
2388
2389 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2390 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2391 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002392 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002393 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002394 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2395 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002396 }
2397 }
2398 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002399
Petr Kraus9752aae2017-11-24 03:05:50 +01002400 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2401 if (pCreateInfos[i].basePipelineIndex != -1) {
2402 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002403 skip |=
2404 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002405 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002406 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002407 "and pCreateInfos->basePipelineIndex is not -1.",
2408 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002409 }
2410 }
2411
Petr Kraus9752aae2017-11-24 03:05:50 +01002412 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2413 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002414 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002415 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002416 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002417 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2418 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002419 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002420 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002421 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002422 skip |=
2423 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2424 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2425 "index into the pCreateInfos array, of size %d.",
2426 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002427 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002428 }
2429 }
2430
sfricke-samsung898cf222020-05-15 23:10:19 -07002431 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2432 skip |= LogError(
2433 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2434 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE",
2435 i);
2436 }
2437
Petr Kraus9752aae2017-11-24 03:05:50 +01002438 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002439 if (!device_extensions.vk_nv_fill_rectangle) {
2440 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2441 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002442 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2443 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2444 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2445 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002446 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2447 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002448 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2449 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002450 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2451 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2452 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002453 }
2454 } else {
2455 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2456 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2457 (physical_device_features.fillModeNonSolid == false)) {
2458 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002459 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2460 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002461 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2462 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2463 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002464 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002465 }
Petr Kraus299ba622017-11-24 03:09:03 +01002466
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002467 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002468 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002469 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2470 "The line width state is static (pCreateInfos[%" PRIu32
2471 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2472 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2473 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2474 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002475 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002476 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002477 }
2478 }
2479
2480 return skip;
2481}
2482
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002483bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2484 uint32_t createInfoCount,
2485 const VkComputePipelineCreateInfo *pCreateInfos,
2486 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002487 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002488 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002489 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002490 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002491 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002492 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002493 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2494 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002495 skip |=
2496 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2497 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2498 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2499 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002500 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002501
2502 // Make sure compute stage is selected
2503 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002504 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2505 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2506 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002507 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002508 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002509 return skip;
2510}
2511
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002512bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002513 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002514 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002515
2516 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002517 const auto &features = physical_device_features;
2518 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002519
John Zulauf71968502017-10-26 13:51:15 -06002520 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2521 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002522 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2523 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2524 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2525 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002526 }
2527
2528 // Anistropy cannot be enabled in sampler unless enabled as a feature
2529 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002530 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2531 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2532 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002533 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002534 }
John Zulauf71968502017-10-26 13:51:15 -06002535
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002536 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2537 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002538 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2539 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2540 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2541 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002542 }
2543 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002544 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2545 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2546 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2547 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002548 }
2549 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002550 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2551 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2552 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2553 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002554 }
2555 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2556 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2557 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2558 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002559 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2560 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2561 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2562 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2563 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2564 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002565 }
2566 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002567 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2568 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2569 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002570 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002571 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002572 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2573 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2574 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002575 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002576 }
2577
2578 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2579 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002580 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2581 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07002582 const auto *sampler_reduction = lvl_find_in_chain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
2583 if (sampler_reduction != nullptr) {
2584 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
2585 skip |= LogError(
2586 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
2587 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
2588 }
2589 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002590 }
2591
2592 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2593 // valid VkBorderColor value
2594 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2595 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2596 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002597 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2598 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002599 }
2600
2601 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2602 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002603 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002604 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2605 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2606 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002607 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002608 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2609 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2610 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002611 }
John Zulauf275805c2017-10-26 15:34:49 -06002612
2613 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002614 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002615 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2616 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002617 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2618 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2619 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002620 }
2621 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002622
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002623 // Check for valid Lod range
2624 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002625 skip |=
2626 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2627 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002628 }
2629
2630 // Check mipLodBias to device limit
2631 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002632 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2633 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2634 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002635 }
2636
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002637 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2638 if (sampler_conversion != nullptr) {
2639 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2640 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2641 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2642 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002643 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002644 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002645 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2646 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2647 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2648 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2649 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2650 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2651 }
2652 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02002653
2654 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
2655 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
2656 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
2657 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2658 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2659 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
2660 }
2661 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
2662 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
2663 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2664 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2665 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
2666 }
2667 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
2668 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
2669 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2670 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
2671 pCreateInfo->minLod, pCreateInfo->maxLod);
2672 }
2673 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2674 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
2675 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2676 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
2677 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
2678 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2679 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
2680 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
2681 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2682 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
2683 }
2684 if (pCreateInfo->anisotropyEnable) {
2685 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
2686 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2687 "pCreateInfo->anisotropyEnable must be VK_FALSE");
2688 }
2689 if (pCreateInfo->compareEnable) {
2690 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
2691 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2692 "pCreateInfo->compareEnable must be VK_FALSE");
2693 }
2694 if (pCreateInfo->unnormalizedCoordinates) {
2695 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
2696 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2697 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
2698 }
2699 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002700 }
2701
Tony-LunarG7337b312020-04-15 16:40:25 -06002702 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
2703 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
2704 if (!device_extensions.vk_ext_custom_border_color) {
2705 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2706 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
2707 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
2708 }
2709 auto custom_create_info = lvl_find_in_chain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
2710 if (!custom_create_info) {
2711 skip |=
2712 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
2713 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
2714 "struct in pNext chain.\n",
2715 string_VkBorderColor(pCreateInfo->borderColor));
2716 } else {
2717 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
2718 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
2719 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
2720 !FormatIsSampledFloat(custom_create_info->format)))) {
2721 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
2722 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
2723 "whose type does not match\n",
2724 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
2725 ;
2726 }
2727 }
2728 }
2729
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002730 return skip;
2731}
2732
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002733bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2734 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2735 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002736 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002737 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002738
2739 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2740 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2741 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2742 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002743 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2744 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2745 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2746 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2747 ++descriptor_index) {
2748 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07002749 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002750 "vkCreateDescriptorSetLayout: required parameter "
2751 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2752 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002753 }
2754 }
2755 }
2756
2757 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2758 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2759 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002760 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2761 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2762 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2763 "values.",
2764 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002765 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07002766
2767 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
2768 (pCreateInfo->pBindings[i].stageFlags != 0) &&
2769 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
2770 skip |=
2771 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
2772 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
2773 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
2774 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
2775 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
2776 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002777 }
2778 }
2779 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002780 return skip;
2781}
2782
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002783bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2784 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002785 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002786 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2787 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2788 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002789 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2790 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002791}
2792
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002793bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2794 const VkWriteDescriptorSet *pDescriptorWrites,
2795 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002796 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002797
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002798 if (pDescriptorWrites != NULL) {
2799 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2800 // descriptorCount must be greater than 0
2801 if (pDescriptorWrites[i].descriptorCount == 0) {
2802 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002803 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2804 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002805 }
2806
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002807 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2808 if (validateDstSet) {
2809 // dstSet must be a valid VkDescriptorSet handle
2810 skip |= validate_required_handle(vkCallingFunction,
2811 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2812 pDescriptorWrites[i].dstSet);
2813 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002814
2815 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2816 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2817 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2818 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2819 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2820 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2821 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05002822 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
2823 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002824 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002825 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2826 "%s(): if pDescriptorWrites[%d].descriptorType is "
2827 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2828 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2829 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2830 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002831 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2832 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05002833 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
2834 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002835 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2836 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002837 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002838 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2839 ParameterName::IndexVector{i, descriptor_index}),
2840 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002841 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002842 }
2843 }
2844 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2845 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2846 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2847 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2848 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2849 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2850 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05002851 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002852 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002853 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2854 "%s(): if pDescriptorWrites[%d].descriptorType is "
2855 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2856 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2857 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2858 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002859 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05002860 const auto *robustness2_features =
2861 lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
2862 if (robustness2_features && robustness2_features->nullDescriptor) {
2863 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount;
2864 ++descriptorIndex) {
2865 if (pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer == VK_NULL_HANDLE &&
2866 (pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset != 0 ||
2867 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range != VK_WHOLE_SIZE)) {
2868 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
2869 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
2870 "offset (" PRIu64 ") must be zero and range (" PRIu64 ") must be VK_WHOLE_SIZE.",
2871 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset,
2872 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range);
2873 }
2874 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002875 }
2876 }
2877 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2878 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05002879 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002880 }
2881
2882 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2883 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002884 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002885 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2886 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2887 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002888 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002889 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2890 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2891 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2892 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002893 }
2894 }
2895 }
2896 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2897 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002898 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002899 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2900 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2901 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002902 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002903 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
2904 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2905 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2906 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002907 }
2908 }
2909 }
2910 }
sourav parmara96ab1a2020-04-25 16:28:23 -07002911 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
2912 // or VkWriteDescriptorSetInlineUniformBlockEX
2913 if (pDescriptorWrites[i].pNext) {
2914 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06002915 const auto *pnext_struct =
sourav parmara96ab1a2020-04-25 16:28:23 -07002916 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06002917 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
sourav parmara96ab1a2020-04-25 16:28:23 -07002918 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
2919 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
2920 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
2921 "accelerationStructureCount %d member equals descriptorCount %d.",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06002922 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
sourav parmara96ab1a2020-04-25 16:28:23 -07002923 pDescriptorWrites[i].descriptorCount);
2924 }
2925 // further checks only if we have right structtype
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06002926 if (pnext_struct) {
2927 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
sourav parmara96ab1a2020-04-25 16:28:23 -07002928 skip |= LogError(
2929 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
2930 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
2931 ".",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06002932 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07002933 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06002934 if (pnext_struct->accelerationStructureCount == 0) {
sourav parmara96ab1a2020-04-25 16:28:23 -07002935 skip |= LogError(
2936 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
2937 "%s(): accelerationStructureCount must be greater than 0 .");
2938 }
2939 }
2940 }
2941 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002942 }
2943 }
2944 return skip;
2945}
2946
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002947bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
2948 const VkWriteDescriptorSet *pDescriptorWrites,
2949 uint32_t descriptorCopyCount,
2950 const VkCopyDescriptorSet *pDescriptorCopies) const {
2951 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
2952}
2953
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002954bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002955 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002956 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002957 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
2958}
2959
2960bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002961 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002962 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002963 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
2964}
2965
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002966bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
2967 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002968 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002969 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002970
2971 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2972 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2973 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002974 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
2975 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002976 return skip;
2977}
2978
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002979bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002980 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002981 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02002982
2983 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
2984 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002985 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
2986
Petr Krause7bb9e82019-08-11 21:34:43 +02002987 // Implicit VUs
2988 // validate only sType here; pointer has to be validated in core_validation
2989 const bool kNotRequired = false;
2990 const char *kNoVUID = nullptr;
2991 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
2992 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
2993 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002994
Petr Krause7bb9e82019-08-11 21:34:43 +02002995 if (pInfo) {
2996 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
2997 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
2998 skip |= validate_struct_pnext(
2999 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
3000 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08003001 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
3002 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003003
Petr Krause7bb9e82019-08-11 21:34:43 +02003004 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003005
Petr Krause7bb9e82019-08-11 21:34:43 +02003006 // Explicit VUs
3007 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003008 skip |= LogError(
3009 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02003010 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3011 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003012 }
Petr Krause7bb9e82019-08-11 21:34:43 +02003013
3014 if (physical_device_features.inheritedQueries) {
3015 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003016 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06003017 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02003018 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02003019 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003020 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02003021 }
3022
3023 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02003024 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003025 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003026 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02003027 } else { // !pipelineStatisticsQuery
3028 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
3029 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003030 }
Petr Kraus139757b2019-08-15 17:19:33 +02003031
3032 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
3033 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003034 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02003035 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3036 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003037 skip |= LogError(
3038 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02003039 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3040 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3041 }
3042 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003043 }
3044
3045 return skip;
3046}
3047
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003048bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003049 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003050 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003051
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003052 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003053 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003054 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3055 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3056 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003057 }
3058 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003059 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3060 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3061 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003062 }
3063 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003064 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003065 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003066 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3067 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3068 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3069 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003070 }
3071 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003072
3073 if (pViewports) {
3074 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3075 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003076 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003077 skip |= manual_PreCallValidateViewport(
3078 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003079 }
3080 }
3081
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003082 return skip;
3083}
3084
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003085bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003086 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003087 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003088
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003089 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003090 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003091 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3092 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3093 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003094 }
3095 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003096 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3097 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3098 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003099 }
3100 } else { // multiViewport enabled
3101 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003102 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003103 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3104 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3105 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3106 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003107 }
3108 }
3109
Petr Kraus6260f0a2018-02-27 21:15:55 +01003110 if (pScissors) {
3111 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3112 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003113
Petr Kraus6260f0a2018-02-27 21:15:55 +01003114 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003115 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3116 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3117 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003118 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003119
Petr Kraus6260f0a2018-02-27 21:15:55 +01003120 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003121 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3122 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3123 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003124 }
3125
3126 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3127 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003128 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3129 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3130 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3131 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003132 }
3133
3134 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3135 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003136 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3137 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3138 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3139 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003140 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003141 }
3142 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003143
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003144 return skip;
3145}
3146
Jeff Bolz5c801d12019-10-09 10:38:45 -05003147bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003148 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003149
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003150 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003151 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3152 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003153 }
3154
3155 return skip;
3156}
3157
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003158bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003159 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003160 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003161 if (vertexCount == 0) {
3162 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
3163 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003164 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003165 }
3166
3167 if (instanceCount == 0) {
3168 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
3169 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003170 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003171 }
3172 return skip;
3173}
3174
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003175bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003176 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003177 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003178
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003179 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003180 skip |= LogError(device, kVUID_PVError_DeviceFeature,
3181 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003182 }
3183 return skip;
3184}
3185
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003186bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003187 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003188 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003189 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003190 skip |=
3191 LogError(device, kVUID_PVError_DeviceFeature,
3192 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003193 }
3194 return skip;
3195}
3196
sfricke-samsungf692b972020-05-02 08:00:45 -07003197bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3198 VkDeviceSize countBufferOffset, bool khr) const {
3199 bool skip = false;
3200 const char *apiName = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
3201 if (offset & 3) {
3202 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
3203 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3204 }
3205
3206 if (countBufferOffset & 3) {
3207 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
3208 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3209 countBufferOffset);
3210 }
3211 return skip;
3212}
3213
3214bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3215 VkDeviceSize offset, VkBuffer countBuffer,
3216 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3217 uint32_t stride) const {
3218 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3219}
3220
3221bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3222 VkDeviceSize offset, VkBuffer countBuffer,
3223 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3224 uint32_t stride) const {
3225 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3226}
3227
3228bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3229 VkDeviceSize countBufferOffset, bool khr) const {
3230 bool skip = false;
3231 const char *apiName = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
3232 if (offset & 3) {
3233 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
3234 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3235 }
3236
3237 if (countBufferOffset & 3) {
3238 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
3239 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3240 countBufferOffset);
3241 }
3242 return skip;
3243}
3244
3245bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3246 VkDeviceSize offset, VkBuffer countBuffer,
3247 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3248 uint32_t stride) const {
3249 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3250}
3251
3252bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3253 VkDeviceSize offset, VkBuffer countBuffer,
3254 VkDeviceSize countBufferOffset,
3255 uint32_t maxDrawCount, uint32_t stride) const {
3256 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3257}
3258
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003259bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3260 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003261 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003262 bool skip = false;
3263 for (uint32_t rect = 0; rect < rectCount; rect++) {
3264 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003265 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3266 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003267 }
sfricke-samsung10867682020-04-25 02:20:39 -07003268 if (pRects[rect].rect.extent.width == 0) {
3269 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3270 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3271 }
3272 if (pRects[rect].rect.extent.height == 0) {
3273 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3274 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3275 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003276 }
3277 return skip;
3278}
3279
Andrew Fobel3abeb992020-01-20 16:33:22 -05003280bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3281 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3282 VkImageFormatProperties2 *pImageFormatProperties,
3283 const char *apiName) const {
3284 bool skip = false;
3285
3286 if (pImageFormatInfo != nullptr) {
3287 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
3288 if (image_stencil_struct != nullptr) {
3289 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3290 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3291 // No flags other than the legal attachment bits may be set
3292 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3293 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003294 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3295 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3296 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3297 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3298 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003299 }
3300 }
3301 }
3302 }
3303
3304 return skip;
3305}
3306
3307bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3308 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3309 VkImageFormatProperties2 *pImageFormatProperties) const {
3310 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3311 "vkGetPhysicalDeviceImageFormatProperties2");
3312}
3313
3314bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3315 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3316 VkImageFormatProperties2 *pImageFormatProperties) const {
3317 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3318 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3319}
3320
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003321bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3322 VkImageLayout srcImageLayout, VkImage dstImage,
3323 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003324 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003325 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003326
Dave Houltonf5217612018-02-02 16:18:52 -07003327 VkImageAspectFlags legal_aspect_flags =
3328 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 -07003329 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003330 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3331 }
3332
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003333 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003334 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003335 skip |= LogError(
3336 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003337 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003338 }
Dave Houltonf5217612018-02-02 16:18:52 -07003339 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003340 skip |= LogError(
3341 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003342 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003343 }
3344 }
3345 return skip;
3346}
3347
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003348bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3349 VkImageLayout srcImageLayout, VkImage dstImage,
3350 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003351 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003352 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003353
Dave Houltonf5217612018-02-02 16:18:52 -07003354 VkImageAspectFlags legal_aspect_flags =
3355 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 -07003356 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003357 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3358 }
3359
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003360 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003361 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003362 skip |= LogError(
3363 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003364 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
3365 }
Dave Houltonf5217612018-02-02 16:18:52 -07003366 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003367 skip |= LogError(
3368 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003369 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
3370 }
3371 }
3372 return skip;
3373}
3374
sfricke-samsung3999ef62020-02-09 17:05:59 -08003375bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3376 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3377 bool skip = false;
3378
3379 if (pRegions != nullptr) {
3380 for (uint32_t i = 0; i < regionCount; i++) {
3381 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003382 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3383 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003384 }
3385 }
3386 }
3387 return skip;
3388}
3389
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003390bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
3391 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003392 uint32_t regionCount,
3393 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003394 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003395
Dave Houltonf5217612018-02-02 16:18:52 -07003396 VkImageAspectFlags legal_aspect_flags =
3397 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 -07003398 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003399 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3400 }
3401
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003402 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003403 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003404 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
3405 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
3406 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003407 }
3408 }
3409 return skip;
3410}
3411
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003412bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
3413 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003414 uint32_t regionCount,
3415 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003416 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003417
Dave Houltonf5217612018-02-02 16:18:52 -07003418 VkImageAspectFlags legal_aspect_flags =
3419 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 -07003420 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003421 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3422 }
3423
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003424 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003425 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Petr Kraus3e6cd032020-04-14 20:41:16 +02003426 skip |= LogError(
3427 device, kVUID_PVError_UnrecognizedValue,
3428 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
3429 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003430 }
3431 }
3432 return skip;
3433}
3434
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003435bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003436 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3437 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003438 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003439
3440 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003441 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3442 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3443 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003444 }
3445
3446 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003447 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3448 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3449 "), must be greater than zero and less than or equal to 65536.",
3450 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003451 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003452 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3453 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3454 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003455 }
3456 return skip;
3457}
3458
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003459bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003460 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003461 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003462
3463 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003464 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3465 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3466 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003467 }
3468
3469 if (size != VK_WHOLE_SIZE) {
3470 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003471 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003472 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3473 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003474 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003475 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3476 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003477 }
3478 }
3479 return skip;
3480}
3481
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003482bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003483 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003484 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003485 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003486
3487 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003488 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3489 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3490 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3491 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003492 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3493 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3494 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003495 }
3496
3497 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3498 // queueFamilyIndexCount uint32_t values
3499 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003500 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3501 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3502 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3503 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003504 }
3505 }
3506
Dave Houlton413a6782018-05-22 13:01:54 -06003507 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003508 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003509 }
3510
3511 return skip;
3512}
3513
Jeff Bolz5c801d12019-10-09 10:38:45 -05003514bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003515 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003516
3517 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003518 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3519 if (present_regions) {
3520 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003521 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003522 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3523 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003524 skip |= LogError(device, kVUID_PVError_InvalidUsage,
3525 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3526 "extension swapchainCount is %i. These values must be equal.",
3527 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003528 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003529 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003530 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3531 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003532 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3533 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3534 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003535 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003536 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003537 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003538 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003539 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003540 }
3541 }
3542
3543 return skip;
3544}
3545
3546#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003547bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3548 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3549 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003550 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003551 bool skip = false;
3552
3553 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003554 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3555 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003556 }
3557
3558 return skip;
3559}
3560#endif // VK_USE_PLATFORM_WIN32_KHR
3561
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003562bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003563 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003564 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003565 bool skip = false;
3566
3567 if (pCreateInfo) {
3568 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003569 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3570 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003571 }
3572
3573 if (pCreateInfo->pPoolSizes) {
3574 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3575 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003576 skip |= LogError(
3577 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003578 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003579 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003580 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3581 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003582 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3583 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3584 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3585 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3586 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003587 }
Petr Krausc8655be2017-09-27 18:56:51 +02003588 }
3589 }
3590 }
3591
3592 return skip;
3593}
3594
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003595bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003596 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003597 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003598
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003599 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003600 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003601 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3602 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3603 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003604 }
3605
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003606 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003607 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003608 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3609 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3610 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003611 }
3612
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003613 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003614 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003615 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3616 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3617 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003618 }
3619
3620 return skip;
3621}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003622
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003623bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003624 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003625 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003626
3627 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003628 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3629 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003630 }
3631 return skip;
3632}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003633
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003634bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3635 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003636 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003637 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003638
3639 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003640 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003641 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003642 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3643 "vkCmdDispatch(): baseGroupX (%" PRIu32
3644 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3645 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003646 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003647 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3648 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3649 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3650 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003651 }
3652
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003653 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003654 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003655 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3656 "vkCmdDispatch(): baseGroupY (%" PRIu32
3657 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3658 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003659 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003660 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3661 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3662 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3663 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003664 }
3665
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003666 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003667 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003668 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3669 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3670 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3671 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003672 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003673 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3674 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3675 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3676 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003677 }
3678
3679 return skip;
3680}
3681
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003682bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3683 VkPipelineBindPoint pipelineBindPoint,
3684 VkPipelineLayout layout, uint32_t set,
3685 uint32_t descriptorWriteCount,
3686 const VkWriteDescriptorSet *pDescriptorWrites) const {
3687 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3688}
3689
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003690bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3691 uint32_t firstExclusiveScissor,
3692 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003693 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003694 bool skip = false;
3695
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003696 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003697 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003698 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003699 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3700 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3701 ") is not 0.",
3702 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003703 }
3704 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003705 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003706 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3707 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3708 ") is not 1.",
3709 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003710 }
3711 } else { // multiViewport enabled
3712 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003713 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003714 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3715 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3716 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3717 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003718 }
3719 }
3720
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003721 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003722 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3723 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3724 ") must be less than maxViewports (=%" PRIu32 ").",
3725 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003726 }
3727
3728 if (pExclusiveScissors) {
3729 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3730 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3731
3732 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003733 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3734 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3735 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003736 }
3737
3738 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003739 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3740 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3741 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003742 }
3743
3744 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3745 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003746 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3747 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3748 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3749 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003750 }
3751
3752 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3753 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003754 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3755 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3756 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3757 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003758 }
3759 }
3760 }
3761
3762 return skip;
3763}
3764
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003765bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3766 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003767 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003768 bool skip = false;
3769 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003770 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3771 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3772 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003773 } else {
3774 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3775 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003776 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3777 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3778 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3779 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003780 }
3781 }
3782
3783 return skip;
3784}
3785
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003786bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3787 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003788 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003789 bool skip = false;
3790
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003791 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003792 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003793 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003794 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3795 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3796 ") is not 0.",
3797 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003798 }
3799 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003800 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003801 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3802 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3803 ") is not 1.",
3804 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003805 }
3806 }
3807
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003808 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003809 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3810 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3811 ") must be less than maxViewports (=%" PRIu32 ").",
3812 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003813 }
3814
3815 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003816 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003817 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3818 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3819 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3820 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003821 }
3822
3823 return skip;
3824}
3825
Jeff Bolz5c801d12019-10-09 10:38:45 -05003826bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3827 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3828 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003829 bool skip = false;
3830
Dave Houlton142c4cb2018-10-17 15:04:41 -06003831 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003832 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3833 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3834 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003835 }
3836
3837 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003838 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003839 }
3840
3841 return skip;
3842}
3843
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003844bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003845 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003846 bool skip = false;
3847
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003848 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003849 skip |= LogError(
3850 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003851 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3852 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003853 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003854 }
3855
3856 return skip;
3857}
3858
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003859bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3860 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003861 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003862 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003863 static const int condition_multiples = 0b0011;
3864 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003865 skip |= LogError(
3866 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003867 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003868 }
Lockee1c22882019-06-10 16:02:54 -06003869 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003870 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3871 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3872 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3873 stride);
Lockee1c22882019-06-10 16:02:54 -06003874 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003875 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003876 skip |= LogError(
3877 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3878 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003879 }
3880
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003881 return skip;
3882}
3883
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003884bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3885 VkDeviceSize offset, VkBuffer countBuffer,
3886 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003887 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003888 bool skip = false;
3889
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003890 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003891 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3892 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3893 "), is not a multiple of 4.",
3894 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003895 }
3896
3897 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003898 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
3899 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3900 "), is not a multiple of 4.",
3901 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003902 }
3903
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003904 return skip;
3905}
3906
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003907bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003908 const VkAllocationCallbacks *pAllocator,
3909 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003910 bool skip = false;
3911
3912 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3913 if (pCreateInfo != nullptr) {
3914 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3915 // VkQueryPipelineStatisticFlagBits values
3916 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3917 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003918 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
3919 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3920 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3921 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003922 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07003923 if (pCreateInfo->queryCount == 0) {
3924 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
3925 "vkCreateQueryPool(): queryCount must be greater than zero.");
3926 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003927 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003928 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003929}
3930
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003931bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3932 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003933 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003934 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3935 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003936}
3937
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003938void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003939 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3940 VkResult result) {
3941 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003942 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003943}
3944
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003945void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003946 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3947 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003948 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003949 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003950 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003951}
3952
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003953void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
3954 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003955 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003956 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003957 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003958}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003959
3960bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003961 const VkAllocationCallbacks *pAllocator,
3962 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003963 bool skip = false;
3964
3965 if (pAllocateInfo) {
3966 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
3967 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003968 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
3969 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003970 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003971
3972 VkMemoryAllocateFlags flags = 0;
3973 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
3974 if (flags_info) {
3975 flags = flags_info->flags;
3976 }
3977
3978 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
3979 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
3980 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003981 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
3982 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
3983 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003984 }
3985
3986#ifdef VK_USE_PLATFORM_WIN32_KHR
3987 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
3988#endif
3989 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
3990 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
3991#ifdef VK_USE_PLATFORM_ANDROID_KHR
3992 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
3993#endif
3994
3995 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003996 skip |= LogError(
3997 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003998 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
3999 }
4000 if (
4001#ifdef VK_USE_PLATFORM_WIN32_KHR
4002 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4003#endif
4004 (import_memory_fd && import_memory_fd->handleType) ||
4005#ifdef VK_USE_PLATFORM_ANDROID_KHR
4006 (import_memory_ahb && import_memory_ahb->buffer) ||
4007#endif
4008 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004009 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4010 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004011 }
4012 }
4013
4014 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004015 VkBool32 capture_replay = false;
4016 VkBool32 buffer_device_address = false;
4017 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
4018 if (vulkan_12_features) {
4019 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4020 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4021 } else {
4022 const auto *bda_features =
4023 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
4024 if (bda_features) {
4025 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4026 buffer_device_address = bda_features->bufferDeviceAddress;
4027 }
4028 }
4029 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004030 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
4031 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
4032 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004033 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004034 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004035 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
4036 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004037 }
4038 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004039 }
4040 return skip;
4041}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004042
Jason Macnak192fa0e2019-07-26 15:07:16 -07004043bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004044 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004045 bool skip = false;
4046
4047 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4048 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4049 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004050 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004051 } else {
4052 uint32_t vertex_component_size = 0;
4053 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4054 vertex_component_size = 4;
4055 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4056 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4057 vertex_component_size = 2;
4058 }
4059 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004060 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004061 }
4062 }
4063
4064 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4065 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004066 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004067 } else {
4068 uint32_t index_element_size = 0;
4069 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4070 index_element_size = 4;
4071 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4072 index_element_size = 2;
4073 }
4074 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004075 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004076 }
4077 }
4078 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4079 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004080 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004081 }
4082 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004083 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004084 }
4085 }
4086
4087 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004088 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004089 }
4090
4091 return skip;
4092}
4093
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004094bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4095 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004096 bool skip = false;
4097
4098 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004099 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004100 }
4101 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004102 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004103 }
4104
4105 return skip;
4106}
4107
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004108bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4109 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004110 bool skip = false;
4111 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004112 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004113 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004114 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004115 }
4116 return skip;
4117}
4118
4119bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004120 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004121 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004122 bool skip = false;
4123 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004124 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4125 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4126 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004127 }
4128 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004129 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4130 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4131 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004132 }
4133 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4134 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004135 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4136 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4137 "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 -07004138 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004139 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004140 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004141 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4142 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004143 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4144 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004145 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004146 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004147 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4148 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4149 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004150 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004151 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004152 uint64_t total_triangle_count = 0;
4153 for (uint32_t i = 0; i < info.geometryCount; i++) {
4154 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004155
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004156 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004157
Jason Macnak5c954952019-07-09 15:46:12 -07004158 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4159 continue;
4160 }
4161 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4162 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004163 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004164 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4165 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4166 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004167 }
4168 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004169 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4170 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4171 for (uint32_t i = 1; i < info.geometryCount; i++) {
4172 const VkGeometryNV &geometry = info.pGeometries[i];
4173 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004174 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004175 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4176 "info.pGeometries[0].geometryType.",
4177 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004178 }
4179 }
4180 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004181 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4182 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4183 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4184 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4185 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4186 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4187 }
4188 }
4189 skip |=
4190 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004191 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004192 return skip;
4193}
4194
Ricardo Garciaa4935972019-02-21 17:43:18 +01004195bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4196 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004197 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004198 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004199 if (pCreateInfo) {
4200 if ((pCreateInfo->compactedSize != 0) &&
4201 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004202 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4203 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4204 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4205 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004206 }
Jason Macnak5c954952019-07-09 15:46:12 -07004207
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004208 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004209 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004210 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004211 return skip;
4212}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004213
Jeff Bolz5c801d12019-10-09 10:38:45 -05004214bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4215 const VkAccelerationStructureInfoNV *pInfo,
4216 VkBuffer instanceData, VkDeviceSize instanceOffset,
4217 VkBool32 update, VkAccelerationStructureNV dst,
4218 VkAccelerationStructureNV src, VkBuffer scratch,
4219 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004220 bool skip = false;
4221
4222 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004223 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004224 }
4225
4226 return skip;
4227}
4228
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004229bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4230 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4231 VkAccelerationStructureKHR *pAccelerationStructure) const {
4232 bool skip = false;
4233
4234 if (pCreateInfo) {
4235 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
4236 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4237 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4238 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
4239 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
4240 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4241 i);
4242 }
4243 }
4244
4245 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4246 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4247 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
4248 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
4249 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4250 i);
4251 }
4252 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004253 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
4254 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
4255 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
4256 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
4257 skip |= LogError(
4258 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
4259 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
4260 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
4261 }
4262 }
4263 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
4264 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
4265 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
4266 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4267 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
4268 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
4269 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
4270 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
4271 }
4272 }
4273 }
4274
4275 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
4276 pCreateInfo->maxGeometryCount != 1) {
4277 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
4278 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4279 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004280 }
sourav parmard1521802020-06-07 21:49:02 -07004281 // or VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490
4282 if (pCreateInfo->compactedSize == 0 && pCreateInfo->maxGeometryCount == 0) {
4283 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-02993",
4284 "VkAccelerationStructureCreateInfoKHR: If compactedSize is 0 then maxGeometryCount must not be 0.");
4285 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004286
4287 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
4288 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
4289 skip |= LogError(
4290 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
4291 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
4292 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
4293 }
4294
4295 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
4296 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
4297 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
4298 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
4299 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
4300 }
4301
4302 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
4303 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
4304 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
4305 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
4306 if (geometry_type != first_geometry_type) {
4307 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
4308 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
4309 "pGeometryInfos[0].geometryType.",
4310 i);
4311 }
4312 }
4313 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004314 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
4315 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
4316 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
4317 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
4318 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
4319 "maxGeometryCount %d.",
4320 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
4321 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004322 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004323 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4324 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
4325 if (pCreateInfo->deviceAddress != 0) {
4326 skip |=
4327 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
4328 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
4329 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
4330 }
4331 }
sourav parmar83c31b12020-05-06 12:30:54 -07004332 if (!raytracing_features || !(raytracing_features->rayQuery == VK_TRUE || raytracing_features->rayTracing == VK_TRUE)) {
4333 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-rayTracing-03487",
4334 "vkCreateAccelerationStructureKHR: The rayTracing or rayQuery feature must be enabled.");
4335 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004336 return skip;
4337}
4338
Jason Macnak5c954952019-07-09 15:46:12 -07004339bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4340 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004341 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004342 bool skip = false;
4343 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004344 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4345 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004346 }
4347 return skip;
4348}
4349
Peter Chen85366392019-05-14 15:20:11 -04004350bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4351 uint32_t createInfoCount,
4352 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4353 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004354 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004355 bool skip = false;
4356
4357 for (uint32_t i = 0; i < createInfoCount; i++) {
4358 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4359 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004360 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004361 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4362 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4363 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4364 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004365 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004366
4367 const auto *pipeline_cache_contol_features =
4368 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4369 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4370 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4371 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4372 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4373 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4374 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4375 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4376 }
4377 }
4378
sourav parmarf4a78252020-04-10 13:04:21 -07004379 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4380 skip |=
4381 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4382 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4383 }
4384 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4385 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4386 skip |=
4387 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4388 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4389 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4390 }
4391 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4392 if (pCreateInfos[i].basePipelineIndex != -1) {
4393 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4394 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4395 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4396 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4397 "and pCreateInfos->basePipelineIndex is not -1.");
4398 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004399 if (pCreateInfos[i].basePipelineIndex > (int32_t)(i)) {
4400 skip |=
4401 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
4402 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
4403 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
4404 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
4405 "that element.");
4406 }
sourav parmarf4a78252020-04-10 13:04:21 -07004407 }
4408 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4409 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4410 skip |=
4411 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4412 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4413 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4414 "commands pCreateInfos parameter.");
4415 }
4416 } else {
4417 if (pCreateInfos[i].basePipelineIndex != -1) {
4418 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4419 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4420 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4421 }
4422 }
4423 }
4424 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4425 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4426 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4427 }
4428 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4429 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4430 "vkCreateRayTracingPipelinesNV: flags must not include "
4431 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4432 }
4433 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4434 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4435 "vkCreateRayTracingPipelinesNV: flags must not include "
4436 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4437 }
4438 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4439 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4440 "vkCreateRayTracingPipelinesNV: flags must not include "
4441 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4442 }
4443 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4444 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4445 "vkCreateRayTracingPipelinesNV: flags must not include "
4446 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4447 }
4448 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4449 skip |= LogError(
4450 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4451 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4452 }
4453 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4454 skip |= LogError(
4455 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4456 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4457 }
Peter Chen85366392019-05-14 15:20:11 -04004458 }
4459
4460 return skip;
4461}
4462
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004463bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4464 uint32_t createInfoCount,
4465 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4466 const VkAllocationCallbacks *pAllocator,
4467 VkPipeline *pPipelines) const {
4468 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004469 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4470 if (!raytracing_features || raytracing_features->rayTracing == VK_FALSE) {
4471 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracing-03455",
4472 "vkCreateRayTracingPipelinesKHR(): The rayTracing feature must be enabled.");
4473 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004474 for (uint32_t i = 0; i < createInfoCount; i++) {
4475 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4476 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4477 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4478 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4479 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4480 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4481 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4482 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004483 const auto *pipeline_cache_contol_features =
4484 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4485 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4486 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4487 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4488 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4489 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4490 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4491 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4492 }
4493 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004494 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4495 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4496 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4497 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4498 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4499 }
4500 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4501 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4502 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4503 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4504 }
4505 }
4506
sourav parmarf4a78252020-04-10 13:04:21 -07004507 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4508 skip |=
4509 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4510 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4511 }
4512 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4513 if (pCreateInfos[i].pLibraryInterface == NULL)
4514 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4515 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4516 }
4517 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4518 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4519 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4520 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4521 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4522 skip |= LogError(
4523 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4524 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4525 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4526 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4527 "must not be VK_SHADER_UNUSED_KHR");
4528 }
4529 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4530 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4531 skip |= LogError(
4532 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4533 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4534 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4535 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4536 "element must not be VK_SHADER_UNUSED_KHR");
4537 }
4538 }
4539 }
4540 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4541 if (pCreateInfos[i].basePipelineIndex != -1) {
4542 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4543 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4544 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4545 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4546 "and pCreateInfos->basePipelineIndex is not -1.");
4547 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004548 if (pCreateInfos[i].basePipelineIndex > (int32_t)i) {
4549 skip |=
4550 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
4551 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
4552 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
4553 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
4554 "element.");
4555 }
sourav parmarf4a78252020-04-10 13:04:21 -07004556 }
4557 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4558 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4559 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4560 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4561 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4562 "commands pCreateInfos parameter %d.",
4563 pCreateInfos[i].basePipelineIndex, createInfoCount);
4564 }
4565 } else {
4566 if (pCreateInfos[i].basePipelineIndex != -1) {
4567 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4568 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4569 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4570 }
4571 }
4572 }
4573 if (pCreateInfos[i].libraries.libraryCount == 0) {
4574 if (pCreateInfos[i].stageCount == 0) {
4575 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4576 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4577 }
4578 if (pCreateInfos[i].groupCount == 0) {
4579 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4580 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4581 }
4582 } else {
4583 if (pCreateInfos[i].pLibraryInterface == NULL) {
4584 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4585 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4586 }
4587 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004588 }
4589
4590 return skip;
4591}
4592
Mike Schuchardt21638df2019-03-16 10:52:02 -07004593#ifdef VK_USE_PLATFORM_WIN32_KHR
4594bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4595 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004596 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004597 bool skip = false;
4598 if (!device_extensions.vk_khr_swapchain)
4599 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4600 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4601 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4602 if (!device_extensions.vk_khr_surface)
4603 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4604 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4605 skip |=
4606 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4607 if (!device_extensions.vk_ext_full_screen_exclusive)
4608 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4609 skip |= validate_struct_type(
4610 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4611 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4612 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4613 if (pSurfaceInfo != NULL) {
4614 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4615 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4616 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4617
4618 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4619 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4620 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4621 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004622 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4623 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004624
4625 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4626 }
4627 return skip;
4628}
4629#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004630
4631bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4632 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004633 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004634 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4635 bool skip = false;
4636 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4637 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4638 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4639 }
4640 return skip;
4641}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004642
4643bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004644 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004645 bool skip = false;
4646
4647 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004648 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4649 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004650 }
4651
4652 return skip;
4653}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004654
4655bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004656 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004657 bool skip = false;
4658
4659 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004660 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4661 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004662 }
4663
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004664 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06004665 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004666 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4667 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004668 }
4669
4670 return skip;
4671}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004672
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004673bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4674 uint32_t bindingCount, const VkBuffer *pBuffers,
4675 const VkDeviceSize *pOffsets) const {
4676 bool skip = false;
4677 if (firstBinding > device_limits.maxVertexInputBindings) {
4678 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4679 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4680 device_limits.maxVertexInputBindings);
4681 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4682 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4683 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4684 "maxVertexInputBindings (%u)",
4685 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4686 }
4687
Jeff Bolz165818a2020-05-08 11:19:03 -05004688 for (uint32_t i = 0; i < bindingCount; ++i) {
4689 if (pBuffers[i] == VK_NULL_HANDLE) {
4690 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
4691 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
4692 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
4693 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
4694 } else {
4695 if (pOffsets[i] != 0) {
4696 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
4697 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
4698 }
4699 }
4700 }
4701 }
4702
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004703 return skip;
4704}
4705
Mark Lobodzinski84988402019-09-11 15:27:30 -06004706bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004707 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004708 bool skip = false;
4709 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004710 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4711 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004712 }
4713 return skip;
4714}
4715
4716bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004717 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004718 bool skip = false;
4719 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004720 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4721 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004722 }
4723 return skip;
4724}
Petr Kraus3d720392019-11-13 02:52:39 +01004725
4726bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4727 VkSemaphore semaphore, VkFence fence,
4728 uint32_t *pImageIndex) const {
4729 bool skip = false;
4730
4731 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004732 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4733 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004734 }
4735
4736 return skip;
4737}
4738
4739bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4740 uint32_t *pImageIndex) const {
4741 bool skip = false;
4742
4743 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004744 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4745 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004746 }
4747
4748 return skip;
4749}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004750
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06004751bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
4752 uint32_t firstBinding, uint32_t bindingCount,
4753 const VkBuffer *pBuffers,
4754 const VkDeviceSize *pOffsets,
4755 const VkDeviceSize *pSizes) const {
4756 bool skip = false;
4757
4758 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
4759 for (uint32_t i = 0; i < bindingCount; ++i) {
4760 if (pOffsets[i] & 3) {
4761 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
4762 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
4763 }
4764 }
4765
4766 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4767 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
4768 "%s: The firstBinding(%" PRIu32
4769 ") index is greater than or equal to "
4770 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4771 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4772 }
4773
4774 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4775 skip |=
4776 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
4777 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
4778 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4779 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4780 }
4781
4782 for (uint32_t i = 0; i < bindingCount; ++i) {
4783 // pSizes is optional and may be nullptr.
4784 if (pSizes != nullptr) {
4785 if (pSizes[i] != VK_WHOLE_SIZE &&
4786 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
4787 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
4788 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
4789 ") is not VK_WHOLE_SIZE and is greater than "
4790 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
4791 cmd_name, i, pSizes[i]);
4792 }
4793 }
4794 }
4795
4796 return skip;
4797}
4798
4799bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
4800 uint32_t firstCounterBuffer,
4801 uint32_t counterBufferCount,
4802 const VkBuffer *pCounterBuffers,
4803 const VkDeviceSize *pCounterBufferOffsets) const {
4804 bool skip = false;
4805
4806 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
4807 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4808 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
4809 "%s: The firstCounterBuffer(%" PRIu32
4810 ") index is greater than or equal to "
4811 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4812 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4813 }
4814
4815 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4816 skip |=
4817 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
4818 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
4819 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4820 cmd_name, firstCounterBuffer, counterBufferCount,
4821 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4822 }
4823
4824 return skip;
4825}
4826
4827bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
4828 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
4829 const VkBuffer *pCounterBuffers,
4830 const VkDeviceSize *pCounterBufferOffsets) const {
4831 bool skip = false;
4832
4833 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
4834 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4835 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
4836 "%s: The firstCounterBuffer(%" PRIu32
4837 ") index is greater than or equal to "
4838 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4839 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4840 }
4841
4842 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4843 skip |=
4844 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
4845 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
4846 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4847 cmd_name, firstCounterBuffer, counterBufferCount,
4848 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4849 }
4850
4851 return skip;
4852}
4853
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004854bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
4855 uint32_t firstInstance, VkBuffer counterBuffer,
4856 VkDeviceSize counterBufferOffset,
4857 uint32_t counterOffset, uint32_t vertexStride) const {
4858 bool skip = false;
4859
4860 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004861 skip |= LogError(
4862 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004863 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
4864 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
4865 }
4866
4867 return skip;
4868}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004869
4870bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
4871 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4872 const VkAllocationCallbacks *pAllocator,
4873 VkSamplerYcbcrConversion *pYcbcrConversion,
4874 const char *apiName) const {
4875 bool skip = false;
4876
4877 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004878 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004879 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02004880 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
4881 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
4882 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
4883 "samplerYcbcrConversion must be enabled to call %s.", apiName);
4884 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004885 }
4886 return skip;
4887}
4888
4889bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
4890 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4891 const VkAllocationCallbacks *pAllocator,
4892 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4893 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4894 "vkCreateSamplerYcbcrConversion");
4895}
4896
4897bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
4898 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4899 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4900 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4901 "vkCreateSamplerYcbcrConversionKHR");
4902}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004903
4904bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
4905 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
4906 bool skip = false;
4907 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
4908 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
4909
4910 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004911 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
4912 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
4913 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
4914 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
4915 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004916 }
4917 return skip;
4918}
sourav parmara96ab1a2020-04-25 16:28:23 -07004919
4920bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
4921 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4922 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004923 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4924 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4925 skip |=
4926 LogError(device, "", "VUID-vkCopyAccelerationStructureToMemoryKHR-rayTracingHostAccelerationStructureCommands-03447",
4927 "vkCopyAccelerationStructureToMemoryKHR: the "
4928 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
4929 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004930 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4931 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4932 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4933 }
4934 return skip;
4935}
4936
4937bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
4938 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4939 bool skip = false;
4940 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4941 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
4942 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4943 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4944 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004945 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
4946 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07004947 skip |= LogError(
4948 commandBuffer, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pNext-03560",
4949 "vkCmdCopyAccelerationStructureToMemoryKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
4950 "pNext chain of the VkCopyAccelerationStructureToMemoryInfoKHR structure.");
4951 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004952 return skip;
4953}
4954
4955bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
4956 const char *api_name) const {
4957 bool skip = false;
4958 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
4959 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
4960 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
4961 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
4962 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
4963 api_name);
4964 }
4965 return skip;
4966}
4967
4968bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
4969 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4970 bool skip = false;
4971 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
sourav parmar83c31b12020-05-06 12:30:54 -07004972 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4973 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4974 skip |= LogError(
4975 device, "VUID-vkCopyAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03441",
4976 "vkCopyAccelerationStructureKHR(): the "
4977 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled .");
4978 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004979 return skip;
4980}
4981
4982bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
4983 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4984 bool skip = false;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004985 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
4986 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07004987 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureKHR-pNext-03557",
4988 "vkCmdCopyAccelerationStructureKHR(): The VkDeferredOperationInfoKHR structure must not be included in "
4989 "the pNext chain of the VkCopyAccelerationStructureInfoKHR structure.");
4990 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004991 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
4992 return skip;
4993}
4994
4995bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06004996 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07004997 bool skip = false;
4998 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07004999 skip |= LogError(device,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005000 is_cmd ? "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-mode-03413"
Shannon McPhersonafe55122020-05-25 16:20:19 -06005001 : "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005002 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5003 }
5004 return skip;
5005}
5006
5007bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
5008 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5009 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005010 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
5011 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5012 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5013 skip |=
5014 LogError(device, "VUID-vkCopyMemoryToAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03444",
5015 "vkCopyMemoryToAccelerationStructureKHR() :the "
5016 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
5017 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005018 return skip;
5019}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005020
sourav parmara96ab1a2020-04-25 16:28:23 -07005021bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5022 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5023 bool skip = false;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005024 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5025 if (pnext_struct) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005026 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pNext-03564",
5027 "vkCmdCopyMemoryToAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must"
5028 "not be included in the pNext chain of the VkCopyMemoryToAccelerationStructureInfoKHR structure.");
5029 }
sourav parmar83c31b12020-05-06 12:30:54 -07005030 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
5031 return skip;
5032}
5033bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5034 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5035 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5036 bool skip = false;
5037 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5038 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5039 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5040 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5041 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5042 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5043 }
5044 return skip;
5045}
5046bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5047 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5048 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5049 bool skip = false;
5050 if (dataSize < accelerationStructureCount * stride) {
5051 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5052 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5053 "accelerationStructureCount (%d) *stride(%zu).",
5054 dataSize, accelerationStructureCount, stride);
5055 }
5056 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5057 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5058 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5059 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5060 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5061 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5062 }
5063 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5064 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5065 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5066 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5067 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5068 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5069 stride);
5070 }
5071 }
5072 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5073 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5074 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5075 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5076 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5077 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5078 stride);
5079 }
5080 }
5081 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5082 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5083 skip |=
5084 LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-rayTracingHostAccelerationStructureCommands-03454",
5085 "vkWriteAccelerationStructuresPropertiesKHR: the "
5086 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5087 "feature must be enabled ");
5088 }
5089 return skip;
5090}
5091bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5092 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5093 bool skip = false;
5094 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5095 if (!raytracing_features || raytracing_features->rayTracingShaderGroupHandleCaptureReplay == VK_FALSE) {
5096 skip |= LogError(device,
5097 "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingShaderGroupHandleCaptureReplay-03485",
5098 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR: "
5099 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingShaderGroupHandleCaptureReplay"
5100 "must be enabled to call this function.");
5101 }
5102 return skip;
5103}
5104
5105bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
5106 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5107 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5108 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5109 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5110 uint32_t width, uint32_t height, uint32_t depth) const {
5111 bool skip = false;
5112 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5113 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04038",
5114 "vkCmdTraceRaysKHR: The offset member of pCallableShaderBindingTable"
5115 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5116 }
5117 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5118 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04040",
5119 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5120 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5121 }
5122 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5123 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5124 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
5125 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5126 }
5127 // hitShader
5128 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5129 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04032",
5130 "vkCmdTraceRaysKHR: The offset member of pHitShaderBindingTable must be a multiple"
5131 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5132 }
5133 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5134 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04034",
5135 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple"
5136 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5137 }
5138 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5139 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
5140 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be"
5141 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5142 }
5143
5144 // missShader
5145 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5146 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04026",
5147 "vkCmdTraceRaysKHR: The offset member of pMissShaderBindingTable must be a multiple"
5148 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5149 }
5150 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5151 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04028",
5152 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple"
5153 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5154 }
5155 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5156 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5157 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
5158 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5159 }
5160
5161 // raygenShader
5162 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5163 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-04021",
5164 "vkCmdTraceRaysKHR: pRayGenShaderBindingTable->offset must be a multiple"
5165 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5166 }
5167 return skip;
5168}
5169
5170bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer,
5171 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5172 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5173 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5174 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5175 VkBuffer buffer, VkDeviceSize offset) const {
5176 bool skip = false;
5177 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5178 if (!raytracing_features || raytracing_features->rayTracingIndirectTraceRays == VK_FALSE) {
5179 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingIndirectTraceRays-03518",
5180 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectTraceRays "
5181 "feature must be enabled.");
5182 }
5183 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5184 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04038",
5185 "vkCmdTraceRaysIndirectKHR: The offset member of pCallableShaderBindingTable"
5186 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5187 }
5188 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5189 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04040",
5190 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5191 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5192 }
5193 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5194 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
5195 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be"
5196 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5197 }
5198 // hitShader
5199 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5200 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04032",
5201 "vkCmdTraceRaysIndirectKHR: The offset member of pHitShaderBindingTable must be a multiple"
5202 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5203 }
5204 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5205 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04034",
5206 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple"
5207 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5208 }
5209 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5210 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
5211 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be"
5212 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5213 }
5214
5215 // missShader
5216 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5217 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04026",
5218 "vkCmdTraceRaysIndirectKHR: The offset member of pMissShaderBindingTable must be a multiple"
5219 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5220 }
5221 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5222 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04028",
5223 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be a multiple"
5224 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5225 }
5226 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5227 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
5228 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be"
5229 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5230 }
5231
5232 // raygenShader
5233 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5234 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-04021",
5235 "vkCmdTraceRaysIndirectKHR: pRayGenShaderBindingTable->offset must be a multiple"
5236 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5237 }
5238 return skip;
5239}
5240bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5241 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5242 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5243 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5244 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5245 uint32_t width, uint32_t height, uint32_t depth) const {
5246 bool skip = false;
5247 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5248 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5249 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5250 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5251 }
5252 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5253 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5254 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5255 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5256 }
5257 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5258 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5259 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5260 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5261 }
5262
5263 // hitShader
5264 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5265 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5266 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5267 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5268 }
5269 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5270 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5271 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5272 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5273 }
5274 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5275 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5276 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5277 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5278 }
5279
5280 // missShader
5281 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5282 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5283 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5284 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5285 }
5286 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5287 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5288 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5289 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5290 }
5291 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5292 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5293 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5294 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5295 }
5296
5297 // raygenShader
5298 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5299 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5300 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07005301 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5302 }
5303 if (width > device_limits.maxComputeWorkGroupCount[0]) {
5304 skip |=
5305 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
5306 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
5307 }
5308 if (height > device_limits.maxComputeWorkGroupCount[1]) {
5309 skip |=
5310 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
5311 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
5312 }
5313 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
5314 skip |=
5315 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
5316 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07005317 }
5318 return skip;
5319}
5320
5321bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureIndirectKHR(
5322 VkCommandBuffer commandBuffer, const VkAccelerationStructureBuildGeometryInfoKHR *pInfo, VkBuffer indirectBuffer,
5323 VkDeviceSize indirectOffset, uint32_t indirectStride) const {
5324 bool skip = false;
5325 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5326 if (!raytracing_features || raytracing_features->rayTracingIndirectAccelerationStructureBuild == VK_FALSE) {
5327 skip |= LogError(
5328 device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-rayTracingIndirectAccelerationStructureBuild-03535",
5329 "vkCmdBuildAccelerationStructureIndirectKHR: The "
5330 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectAccelerationStructureBuild feature must be enabled.");
5331 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005332 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5333 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005334 skip |=
5335 LogError(device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-pNext-03536",
5336 "vkCmdBuildAccelerationStructureIndirectKHR: The VkDeferredOperationInfoKHR structure must not be included in "
5337 "the pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5338 }
5339 return false;
5340}
5341
5342bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
5343 VkDevice device, const VkAccelerationStructureVersionKHR *version) const {
5344 bool skip = false;
5345 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5346 if (!raytracing_features || !(raytracing_features->rayQuery || raytracing_features->rayTracing)) {
5347 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracing-03565",
5348 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5349 }
5350 return skip;
5351}
5352
5353bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructureKHR(
5354 VkDevice device, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5355 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5356 bool skip = false;
5357 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5358 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005359 skip |= LogError(device, "VUID-vkBuildAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03439",
5360 "vkBuildAccelerationStructureKHR: The "
5361 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5362 "feature must be enabled .");
sourav parmar83c31b12020-05-06 12:30:54 -07005363 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005364 return skip;
5365}
sourav parmara24fb7b2020-05-26 10:50:04 -07005366bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureKHR(
5367 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5368 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5369 bool skip = false;
5370 for (uint32_t i = 0; i < infoCount; ++i) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005371 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfos->pNext);
5372 if (pnext_struct) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005373 skip |=
5374 LogError(commandBuffer, "VUID-vkCmdBuildAccelerationStructureKHR-pNext-03532",
5375 "vkCmdBuildAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
5376 "pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5377 }
5378 }
5379 return skip;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005380}