blob: da07c4dabe7295b94ec4f3f428a55f6b260522ea [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
22#define NOMINMAX
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
orbea80ddc062019-09-10 10:33:19 -070024#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050025
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070026#include "chassis.h"
27#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060028#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010029
Mark Lobodzinskid4950072017-08-01 13:02:20 -060030static const int MaxParamCheckerStringLength = 256;
31
John Zulauf71968502017-10-26 13:51:15 -060032template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070033inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060034 // Using only < for generality and || for early abort
35 return !((value < min) || (max < value));
36}
37
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070038bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050039 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060040 bool skip = false;
41
42 VkStringErrorFlags result = vk_string_validate(MaxParamCheckerStringLength, validateString);
43
44 if (result == VK_STRING_ERROR_NONE) {
45 return skip;
46 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinskiebee3552018-05-29 09:55:54 -060047 skip = log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
48 "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(), MaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060049 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinskiebee3552018-05-29 09:55:54 -060050 skip = log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, vuid,
51 "%s: string %s contains invalid characters or is badly formed", apiName, stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060052 }
53 return skip;
54}
55
Jeff Bolz46c0ea02019-10-09 13:06:29 -050056bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060057 bool skip = false;
58 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
59 if (api_version_nopatch != effective_api_version) {
60 if (api_version_nopatch < VK_API_VERSION_1_0) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070061 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT,
62 HandleToUint64(instance), kVUIDUndefined,
John Zulauf620755c2018-04-16 11:00:43 -060063 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
64 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
65 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
66 } else {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070067 skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT,
68 HandleToUint64(instance), kVUIDUndefined,
John Zulauf620755c2018-04-16 11:00:43 -060069 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
70 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
71 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
72 }
73 }
74 return skip;
75}
76
Jeff Bolz46c0ea02019-10-09 13:06:29 -050077bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060078 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060079 // Create and use a local instance extension object, as an actual instance has not been created yet
80 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
81 InstanceExtensions local_instance_extensions;
82 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
83
John Zulauf620755c2018-04-16 11:00:43 -060084 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060085 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
86 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060087 }
88
89 return skip;
90}
91
John Zulauf620755c2018-04-16 11:00:43 -060092template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -070093ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
94 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -060095 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -070096 ExtEnabled state =
97 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -060098 return state;
99}
100
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700101bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500102 const VkAllocationCallbacks *pAllocator,
103 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700104 bool skip = false;
105 // Note: From the spec--
106 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
107 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
108 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700109 ? pCreateInfo->pApplicationInfo->apiVersion
110 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700111 skip |= validate_api_version(local_api_version, api_version);
112 skip |= validate_instance_extensions(pCreateInfo);
113 return skip;
114}
115
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700116void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700117 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
118 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700119 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
120 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700121 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700122 this->instance_extensions = instance_data->instance_extensions;
123}
124
locke-lunargb1909cd2019-08-01 23:40:05 -0600125void StatelessValidation::PostCallRecordQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo, VkResult result) {
126 for (uint32_t i = 0; i < pPresentInfo->swapchainCount; ++i) {
127 auto swapchains_result = pPresentInfo->pResults ? pPresentInfo->pResults[i] : result;
128 if (swapchains_result == VK_SUBOPTIMAL_KHR) {
129 log_msg(report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT,
130 HandleToUint64(pPresentInfo->pSwapchains[i]), kVUID_PVPerfWarn_SuboptimalSwapchain,
131 "vkQueuePresentKHR: %s :VK_SUBOPTIMAL_KHR was returned. VK_SUBOPTIMAL_KHR - Presentation will still succeed, "
132 "subject to the window resize behavior, but the swapchain is no longer configured optimally for the surface it "
133 "targets. Applications should query updated surface information and recreate their swapchain at the next "
134 "convenient opportunity.",
135 report_data->FormatHandle(pPresentInfo->pSwapchains[i]).c_str());
136 }
137 }
138}
139
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700140void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700141 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700142 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700143 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700144 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
145 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700146
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700147 // Parmeter validation also uses extension data
148 stateless_validation->device_extensions = this->device_extensions;
149
150 VkPhysicalDeviceProperties device_properties = {};
151 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600152 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700153 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
154
155 if (device_extensions.vk_nv_shading_rate_image) {
156 // Get the needed shading rate image limits
157 auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
158 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600159 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700160 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
161 }
162
163 if (device_extensions.vk_nv_mesh_shader) {
164 // Get the needed mesh shader limits
165 auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>();
166 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600167 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700168 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
169 }
170
Jason Macnak5c954952019-07-09 15:46:12 -0700171 if (device_extensions.vk_nv_ray_tracing) {
172 // Get the needed ray tracing limits
173 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>();
174 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
175 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
176 phys_dev_ext_props.ray_tracing_props = ray_tracing_props;
177 }
178
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700179 if (device_extensions.vk_ext_transform_feedback) {
180 // Get the needed transform feedback limits
181 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
182 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
183 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
184 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
185 }
186
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800187 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
188
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700189 // Save app-enabled features in this device's validation object
190 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200191 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
192 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
193 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
194 if (features2) {
195 tmp_features2_state.features = features2->features;
196 } else if (pCreateInfo->pEnabledFeatures) {
197 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700198 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200199 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700200 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200201 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700202 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200203 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700204}
205
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700206bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500207 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600208 bool skip = false;
209
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200210 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
211 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
212 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600213 }
214
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200215 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
216 skip |=
217 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
218 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
219 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
220 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600221 }
222
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200223 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700224 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
225 bool negative_viewport =
226 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200227 if (maint1 && negative_viewport) {
228 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
229 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
230 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
231 "VK_AMD_negative_viewport_height.");
232 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600233 }
234
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600235 {
236 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
237 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
238 if (khr_bda && ext_bda) {
239 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
240 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
241 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
242 "VK_EXT_buffer_device_address.");
243 }
244 }
245
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600246 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
247 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600248 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
249 if (features2) {
250 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700251 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600252 kVUID_PVError_InvalidUsage,
John Zulaufde972ac2017-10-26 12:07:05 -0600253 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
254 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600255 }
256 }
257
Locke77fad1c2019-04-16 13:09:03 -0600258 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
259 if (features2) {
260 if (!instance_extensions.vk_khr_get_physical_device_properties_2) {
261 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
262 kVUID_PVError_ExtensionNotEnabled,
263 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, "
264 "VK_KHR_get_physical_device_properties2 must be enabled when it creates an instance.");
265 }
266 }
267
268 auto vertex_attribute_divisor_features =
269 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
270 if (vertex_attribute_divisor_features) {
271 bool extension_found = false;
272 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
273 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
274 VK_MAX_EXTENSION_NAME_SIZE)) {
275 extension_found = true;
276 break;
277 }
278 }
279 if (!extension_found) {
280 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
281 kVUID_PVError_ExtensionNotEnabled,
282 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
283 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
284 }
285 }
286
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600287 // Validate pCreateInfo->pQueueCreateInfos
288 if (pCreateInfo->pQueueCreateInfos) {
289 std::unordered_set<uint32_t> set;
290
291 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
292 const uint32_t requested_queue_family = pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex;
293 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700294 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT,
295 HandleToUint64(physicalDevice), "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600296 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
Dave Houltona9df0ce2018-02-07 10:51:23 -0700297 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600298 "index value.",
299 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600300 } else if (set.count(requested_queue_family)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700301 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT,
302 HandleToUint64(physicalDevice), "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600303 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600304 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
305 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600306 } else {
307 set.insert(requested_queue_family);
308 }
309
310 if (pCreateInfo->pQueueCreateInfos[i].pQueuePriorities != nullptr) {
311 for (uint32_t j = 0; j < pCreateInfo->pQueueCreateInfos[i].queueCount; ++j) {
312 const float queue_priority = pCreateInfo->pQueueCreateInfos[i].pQueuePriorities[j];
313 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700314 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT,
315 HandleToUint64(physicalDevice), "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600316 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600317 "] (=%f) is not between 0 and 1 (inclusive).",
318 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600319 }
320 }
321 }
322 }
323 }
324
325 return skip;
326}
327
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500328bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700329 if (!flag) {
330 return log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
331 kVUID_PVError_ExtensionNotEnabled,
332 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
333 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600334 }
335
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700336 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600337}
338
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700339bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500340 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100341 bool skip = false;
342
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700343 const LogMiscParams log_misc{VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, VK_NULL_HANDLE, "vkCreateBuffer"};
Petr Krause5c37652018-01-05 04:05:12 +0100344
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600345 if (pCreateInfo != nullptr) {
Dave Houlton413a6782018-05-22 13:01:54 -0600346 skip |= ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", log_misc);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600347
348 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
349 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
350 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
351 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -0600352 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600353 "VUID-VkBufferCreateInfo-sharingMode-00914",
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600354 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600355 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600356 }
357
358 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
359 // queueFamilyIndexCount uint32_t values
360 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -0600361 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600362 "VUID-VkBufferCreateInfo-sharingMode-00913",
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600363 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
364 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600365 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600366 }
367 }
368
369 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
370 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
371 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
372 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -0600373 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600374 "VUID-VkBufferCreateInfo-flags-00918",
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600375 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600376 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600377 }
378 }
379
380 return skip;
381}
382
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700383bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500384 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600385 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600386
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700387 const LogMiscParams log_misc{VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, VK_NULL_HANDLE, "vkCreateImage"};
Petr Krause5c37652018-01-05 04:05:12 +0100388
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600389 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600390 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
391 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
392 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
393 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -0600394 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600395 "VUID-VkImageCreateInfo-sharingMode-00942",
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600396 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600397 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600398 }
399
400 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
401 // queueFamilyIndexCount uint32_t values
402 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -0600403 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600404 "VUID-VkImageCreateInfo-sharingMode-00941",
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600405 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
406 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600407 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600408 }
409 }
410
Dave Houlton413a6782018-05-22 13:01:54 -0600411 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
412 "VUID-VkImageCreateInfo-extent-00944", log_misc);
413 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
414 "VUID-VkImageCreateInfo-extent-00945", log_misc);
415 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
416 "VUID-VkImageCreateInfo-extent-00946", log_misc);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600417
Dave Houlton413a6782018-05-22 13:01:54 -0600418 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
419 log_misc);
420 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
421 "VUID-VkImageCreateInfo-arrayLayers-00948", log_misc);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600422
Dave Houlton130c0212018-01-29 13:39:56 -0700423 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700424 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
425 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
426 skip |= log_msg(
Dave Houlton413a6782018-05-22 13:01:54 -0600427 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
428 "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600429 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
430 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700431 }
432
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600433 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100434 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
435 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -0600436 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600437 "VUID-VkImageCreateInfo-imageType-00956",
Dave Houltona9df0ce2018-02-07 10:51:23 -0700438 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600439 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600440 }
441
442 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100443 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
444 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600445 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -0600446 VK_NULL_HANDLE, "VUID-VkImageCreateInfo-imageType-00954",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600447 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
448 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
449 ") are not equal.",
450 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100451 }
452
453 if (pCreateInfo->arrayLayers < 6) {
454 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -0600455 VK_NULL_HANDLE, "VUID-VkImageCreateInfo-imageType-00954",
Petr Kraus3f433212018-03-13 12:31:27 +0100456 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600457 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
458 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100459 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600460 }
461
462 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski88529492018-04-01 10:38:15 -0600463 skip |=
464 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600465 "VUID-VkImageCreateInfo-imageType-00957",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600466 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600467 }
468 }
469
Dave Houlton130c0212018-01-29 13:39:56 -0700470 // 3D image may have only 1 layer
471 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski88529492018-04-01 10:38:15 -0600472 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600473 "VUID-VkImageCreateInfo-imageType-00961",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600474 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700475 }
476
477 // If multi-sample, validate type, usage, tiling and mip levels.
478 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
479 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600480 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -0600481 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600482 "VUID-VkImageCreateInfo-samples-02257",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600483 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700484 }
485
486 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
487 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
488 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
489 // At least one of the legal attachment bits must be set
490 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -0600491 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600492 "VUID-VkImageCreateInfo-usage-00966",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600493 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700494 }
495 // No flags other than the legal attachment bits may be set
496 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
497 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -0600498 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600499 "VUID-VkImageCreateInfo-usage-00963",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600500 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700501 }
502 }
503
Jeff Bolzef40fec2018-09-01 22:04:34 -0500504 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600505 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500506 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600507 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
508 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500509 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600510 skip |=
511 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
512 "VUID-VkImageCreateInfo-mipLevels-00958",
513 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
514 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600515 }
516
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600517 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
518 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, VK_NULL_HANDLE,
519 "VUID-VkImageCreateInfo-flags-00950",
520 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
521 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
522 }
523
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700524 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Petr Krausb6f97802018-03-13 12:31:39 +0100525 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, VK_NULL_HANDLE,
Dave Houlton413a6782018-05-22 13:01:54 -0600526 "VUID-VkImageCreateInfo-flags-00969",
Petr Krausb6f97802018-03-13 12:31:39 +0100527 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600528 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100529 }
530
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600531 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
532 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
533 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
534 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -0600535 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600536 "VUID-VkImageCreateInfo-flags-00987",
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600537 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600538 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600539 }
540
541 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
542 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
543 // Linear tiling is unsupported
544 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Dave Houlton413a6782018-05-22 13:01:54 -0600545 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
546 kVUID_PVError_InvalidUsage,
547 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
548 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600549 }
550
551 // Sparse 1D image isn't valid
552 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -0600553 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600554 "VUID-VkImageCreateInfo-imageType-00970",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600555 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600556 }
557
558 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700559 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -0600560 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600561 "VUID-VkImageCreateInfo-imageType-00971",
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600562 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600563 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600564 }
565
566 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700567 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -0600568 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600569 "VUID-VkImageCreateInfo-imageType-00972",
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600570 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600571 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600572 }
573
574 // Multi-sample 2D image when device doesn't support it
575 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700576 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600577 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Dave Houltona9df0ce2018-02-07 10:51:23 -0700578 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600579 "VUID-VkImageCreateInfo-imageType-00973",
Dave Houltona9df0ce2018-02-07 10:51:23 -0700580 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600581 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700582 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600583 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Dave Houltona9df0ce2018-02-07 10:51:23 -0700584 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600585 "VUID-VkImageCreateInfo-imageType-00974",
Dave Houltona9df0ce2018-02-07 10:51:23 -0700586 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600587 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700588 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600589 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Dave Houltona9df0ce2018-02-07 10:51:23 -0700590 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600591 "VUID-VkImageCreateInfo-imageType-00975",
Dave Houltona9df0ce2018-02-07 10:51:23 -0700592 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600593 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700594 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600595 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Dave Houltona9df0ce2018-02-07 10:51:23 -0700596 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -0600597 "VUID-VkImageCreateInfo-imageType-00976",
Dave Houltona9df0ce2018-02-07 10:51:23 -0700598 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600599 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600600 }
601 }
602 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500603
Jeff Bolz9af91c52018-09-01 21:53:57 -0500604 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
605 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
606 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
607 "VUID-VkImageCreateInfo-imageType-02082",
608 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
609 "imageType must be VK_IMAGE_TYPE_2D.");
610 }
611 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
612 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
613 "VUID-VkImageCreateInfo-samples-02083",
614 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
615 "samples must be VK_SAMPLE_COUNT_1_BIT.");
616 }
617 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
618 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
619 "VUID-VkImageCreateInfo-tiling-02084",
620 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
621 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
622 }
623 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500624
625 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600626 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Jeff Bolzef40fec2018-09-01 22:04:34 -0500627 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
628 "VUID-VkImageCreateInfo-flags-02050",
629 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
630 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
631 }
632
Dave Houlton142c4cb2018-10-17 15:04:41 -0600633 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Jeff Bolzef40fec2018-09-01 22:04:34 -0500634 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
635 "VUID-VkImageCreateInfo-flags-02051",
636 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
637 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
638 "not be a depth/stencil format.");
639 }
640
Dave Houlton142c4cb2018-10-17 15:04:41 -0600641 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Jeff Bolzef40fec2018-09-01 22:04:34 -0500642 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
643 "VUID-VkImageCreateInfo-flags-02052",
644 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
645 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
646 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500647 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600648 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Jeff Bolzef40fec2018-09-01 22:04:34 -0500649 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
650 "VUID-VkImageCreateInfo-flags-02053",
651 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
652 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
653 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500654 }
655 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500656
657 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
658 if (image_stencil_struct != nullptr) {
659 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
660 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
661 // No flags other than the legal attachment bits may be set
662 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
663 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
664 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0,
665 "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
666 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
667 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
668 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
669 }
670 }
671
672 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
673 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
674 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
675 skip |=
676 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0,
677 "VUID-VkImageCreateInfo-Format-02536",
678 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
679 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
680 "maxFramebufferWidth");
681 }
682
683 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
684 skip |=
685 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0,
686 "VUID-VkImageCreateInfo-format-02537",
687 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
688 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
689 "maxFramebufferHeight");
690 }
691 }
692
693 if (!physical_device_features.shaderStorageImageMultisample &&
694 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
695 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
696 skip |=
697 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0,
698 "VUID-VkImageCreateInfo-format-02538",
699 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
700 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
701 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
702 }
703
704 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
705 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
706 skip |= log_msg(
707 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0,
708 "VUID-VkImageCreateInfo-format-02795",
709 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
710 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
711 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
712 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
713 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
714 skip |= log_msg(
715 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0,
716 "VUID-VkImageCreateInfo-format-02796",
717 "vkCreateImage(): Depth-stencil image in which usage does not include "
718 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
719 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
720 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
721 }
722
723 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
724 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
725 skip |= log_msg(
726 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0,
727 "VUID-VkImageCreateInfo-format-02797",
728 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
729 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
730 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
731 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
732 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
733 skip |= log_msg(
734 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0,
735 "VUID-VkImageCreateInfo-format-02798",
736 "vkCreateImage(): Depth-stencil image in which usage does not include "
737 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
738 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
739 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
740 }
741 }
742 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600743 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500744
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600745 return skip;
746}
747
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600748bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
749 const ParameterName &parameter_name,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500750 VkDebugReportObjectTypeEXT object_type, uint64_t object = 0) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100751 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100752
753 // Note: for numerical correctness
754 // - float comparisons should expect NaN (comparison always false).
755 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
756
757 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -0700758 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100759 if (v1_f <= 0.0f) return true;
760
761 float intpart;
762 const float fract = modff(v1_f, &intpart);
763
764 assert(std::numeric_limits<float>::radix == 2);
765 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
766 if (intpart >= u32_max_plus1) return false;
767
768 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
769 if (v1_u32 < v2_u32)
770 return true;
771 else if (v1_u32 == v2_u32 && fract == 0.0f)
772 return true;
773 else
774 return false;
775 };
776
777 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
778 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
779 return (v1_f <= v2_f);
780 };
781
782 // width
783 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700784 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100785
786 if (!(viewport.width > 0.0f)) {
787 width_healthy = false;
Dave Houlton413a6782018-05-22 13:01:54 -0600788 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, "VUID-VkViewport-width-01770",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600789 "%s: %s.width (=%f) is not greater than 0.0.", fn_name, parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100790 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
791 width_healthy = false;
Dave Houlton413a6782018-05-22 13:01:54 -0600792 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, "VUID-VkViewport-width-01771",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600793 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600794 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100795 } else if (!f_lte_u32_exact(viewport.width, max_w) && f_lte_u32_direct(viewport.width, max_w)) {
Dave Houlton413a6782018-05-22 13:01:54 -0600796 skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, object_type, object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +0100797 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600798 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600799 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100800 }
801
802 // height
803 bool height_healthy = true;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700804 const bool negative_height_enabled = api_version >= VK_API_VERSION_1_1 || device_extensions.vk_khr_maintenance1 ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700805 device_extensions.vk_amd_negative_viewport_height;
806 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100807
808 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
809 height_healthy = false;
Dave Houlton413a6782018-05-22 13:01:54 -0600810 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, "VUID-VkViewport-height-01772",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600811 "%s: %s.height (=%f) is not greater 0.0.", fn_name, parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100812 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
813 height_healthy = false;
814
Dave Houlton413a6782018-05-22 13:01:54 -0600815 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, "VUID-VkViewport-height-01773",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600816 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
817 ").",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600818 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100819 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
820 height_healthy = false;
821
822 skip |= log_msg(
Dave Houlton413a6782018-05-22 13:01:54 -0600823 report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, object_type, object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +0100824 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600825 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600826 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100827 }
828
829 // x
830 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700831 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100832 x_healthy = false;
Dave Houlton413a6782018-05-22 13:01:54 -0600833 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, "VUID-VkViewport-x-01774",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600834 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
835 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100836 }
837
838 // x + width
839 if (x_healthy && width_healthy) {
840 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700841 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600842 skip |=
843 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, "VUID-VkViewport-x-01232",
844 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
845 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
846 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100847 }
848 }
849
850 // y
851 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700852 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100853 y_healthy = false;
Dave Houlton413a6782018-05-22 13:01:54 -0600854 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, "VUID-VkViewport-y-01775",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600855 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
856 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700857 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100858 y_healthy = false;
Dave Houlton413a6782018-05-22 13:01:54 -0600859 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, "VUID-VkViewport-y-01776",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600860 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
861 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100862 }
863
864 // y + height
865 if (y_healthy && height_healthy) {
866 const float boundary = viewport.y + viewport.height;
867
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700868 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Dave Houlton413a6782018-05-22 13:01:54 -0600869 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, "VUID-VkViewport-y-01233",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600870 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600871 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
872 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700873 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600874 skip |=
875 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, "VUID-VkViewport-y-01777",
876 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
877 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
878 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100879 }
880 }
881
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700882 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100883 // minDepth
884 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Dave Houlton413a6782018-05-22 13:01:54 -0600885 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600886
Petr Krausb3fcdb42018-01-09 22:09:09 +0100887 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600888 "[0.0, 1.0] range.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600889 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100890 }
891
892 // maxDepth
893 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Dave Houlton413a6782018-05-22 13:01:54 -0600894 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600895
Petr Krausb3fcdb42018-01-09 22:09:09 +0100896 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600897 "[0.0, 1.0] range.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600898 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100899 }
900 }
901
902 return skip;
903}
904
Dave Houlton142c4cb2018-10-17 15:04:41 -0600905struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500906 VkShadingRatePaletteEntryNV shadingRate;
907 uint32_t width;
908 uint32_t height;
909};
910
911// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -0600912static SampleOrderInfo sampleOrderInfos[] = {
913 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
914 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
915 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
916 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
917 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
918 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -0500919};
920
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500921bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500922 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -0500923
Jeff Bolz45bf7d62018-09-18 15:39:58 -0500924 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -0500925 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -0500926 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500927 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500928 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -0500929 break;
930 }
931 }
932
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500933 if (sampleOrderInfo == nullptr) {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500934 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
935 "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
936 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
937 "that generates fragments with more than one pixel.");
938 return skip;
939 }
940
Dave Houlton142c4cb2018-10-17 15:04:41 -0600941 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700942 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500943 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
944 "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
Dave Houlton142c4cb2018-10-17 15:04:41 -0600945 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
946 ") must "
Jeff Bolz9af91c52018-09-01 21:53:57 -0500947 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
948 "is set in framebufferNoAttachmentsSampleCounts.",
949 order->sampleCount);
950 }
951
Jeff Bolz9af91c52018-09-01 21:53:57 -0500952 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
953 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
954 "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
Dave Houlton142c4cb2018-10-17 15:04:41 -0600955 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
956 ") must "
957 "be equal to the product of sampleCount (=%" PRIu32
958 "), the fragment width for shadingRate "
Jeff Bolz9af91c52018-09-01 21:53:57 -0500959 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
960 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
961 }
962
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700963 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600964 skip |= log_msg(
965 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
966 "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
967 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
968 ") must "
969 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700970 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -0500971 }
Jeff Bolz9af91c52018-09-01 21:53:57 -0500972
973 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500974 // the first width*height*sampleCount bits to all be set. Note: There is no
975 // guarantee that 64 bits is enough, but practically it's unlikely for an
976 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700977 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -0500978 uint64_t sampleLocationsMask = 0;
979 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
980 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
981 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
982 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
983 "VUID-VkCoarseSampleLocationNV-pixelX-02078",
984 "pixelX must be less than the width (in pixels) of the fragment.");
985 }
986 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
987 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
988 "VUID-VkCoarseSampleLocationNV-pixelY-02079",
989 "pixelY must be less than the height (in pixels) of the fragment.");
990 }
991 if (sampleLoc->sample >= order->sampleCount) {
992 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
993 "VUID-VkCoarseSampleLocationNV-sample-02080",
994 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
995 }
996 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
997 sampleLocationsMask |= 1ULL << idx;
998 }
999
1000 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1001 if (sampleLocationsMask != expectedMask) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001002 skip |= log_msg(
1003 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1004 "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
1005 "The array pSampleLocations must contain exactly one entry for "
1006 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001007 }
1008
1009 return skip;
1010}
1011
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001012bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1013 uint32_t createInfoCount,
1014 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1015 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001016 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001017 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001018
1019 if (pCreateInfos != nullptr) {
1020 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001021 bool has_dynamic_viewport = false;
1022 bool has_dynamic_scissor = false;
1023 bool has_dynamic_line_width = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001024 bool has_dynamic_viewport_w_scaling_nv = false;
1025 bool has_dynamic_discard_rectangle_ext = false;
1026 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001027 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001028 bool has_dynamic_shading_rate_palette_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001029 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001030 if (pCreateInfos[i].pDynamicState != nullptr) {
1031 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1032 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1033 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
1034 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) has_dynamic_viewport = true;
1035 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) has_dynamic_scissor = true;
1036 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) has_dynamic_line_width = true;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001037 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) has_dynamic_viewport_w_scaling_nv = true;
1038 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) has_dynamic_discard_rectangle_ext = true;
1039 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) has_dynamic_sample_locations_ext = true;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001040 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) has_dynamic_exclusive_scissor_nv = true;
Dave Houlton142c4cb2018-10-17 15:04:41 -06001041 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV)
1042 has_dynamic_shading_rate_palette_nv = true;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001043 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) has_dynamic_line_stipple = true;
Petr Kraus299ba622017-11-24 03:09:03 +01001044 }
1045 }
1046
Peter Chen85366392019-05-14 15:20:11 -04001047 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1048 if ((feedback_struct != nullptr) &&
1049 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
1050 skip |=
1051 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, VK_NULL_HANDLE,
1052 "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1053 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1054 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1055 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1056 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
1057 }
1058
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001059 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001060
1061 // Collect active stages
1062 uint32_t active_shaders = 0;
1063 for (uint32_t stages = 0; stages < pCreateInfos[i].stageCount; stages++) {
Spencer Fricked84808f2020-01-20 06:08:01 -08001064 active_shaders |= pCreateInfos[i].pStages[stages].stage;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001065 }
1066
1067 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1068 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1069 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1070 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1071 pCreateInfos[i].pTessellationState,
1072 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1073 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1074
1075 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1076 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1077
1078 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1079 "VkPipelineTessellationDomainOriginStateCreateInfo",
1080 pCreateInfos[i].pTessellationState->pNext,
1081 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1082 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
1083 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext");
1084
1085 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1086 pCreateInfos[i].pTessellationState->flags,
1087 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1088 }
1089
1090 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1091 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1092 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1093 pCreateInfos[i].pInputAssemblyState,
1094 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1095 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1096
1097 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1098 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
1099 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext");
1100
1101 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1102 pCreateInfos[i].pInputAssemblyState->flags,
1103 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1104
1105 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1106 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1107 pCreateInfos[i].pInputAssemblyState->topology,
1108 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1109
1110 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1111 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1112 }
1113
1114 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001115 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001116
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001117 if (pCreateInfos[i].pVertexInputState->flags != 0) {
1118 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1119 "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1120 "vkCreateGraphicsPipelines: pararameter "
1121 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1122 i, vertex_input_state->flags);
1123 }
1124
1125 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1126 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1127 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1128 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1129 pCreateInfos[i].pVertexInputState->pNext, 1,
1130 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
1131 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext");
1132 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1133 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001134 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001135 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1136 skip |=
1137 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1138 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1139 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1140 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1141 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1142
1143 skip |= validate_array(
1144 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1145 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1146 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1147 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1148
1149 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1150 for (uint32_t vertexBindingDescriptionIndex = 0;
1151 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1152 ++vertexBindingDescriptionIndex) {
1153 skip |= validate_ranged_enum(
1154 "vkCreateGraphicsPipelines",
1155 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1156 AllVkVertexInputRateEnums,
1157 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1158 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1159 }
1160 }
1161
1162 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1163 for (uint32_t vertexAttributeDescriptionIndex = 0;
1164 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1165 ++vertexAttributeDescriptionIndex) {
1166 skip |= validate_ranged_enum(
1167 "vkCreateGraphicsPipelines",
1168 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1169 AllVkFormatEnums,
1170 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1171 "VUID-VkVertexInputAttributeDescription-format-parameter");
1172 }
1173 }
1174
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001175 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Peter Kohautc7d9d392018-07-15 00:34:07 +02001176 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1177 "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1178 "vkCreateGraphicsPipelines: pararameter "
1179 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1180 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001181 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001182 }
1183
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001184 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Peter Kohautc7d9d392018-07-15 00:34:07 +02001185 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1186 "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1187 "vkCreateGraphicsPipelines: pararameter "
Peter Kohaut9e92c5c2018-07-17 10:32:17 +02001188 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
Peter Kohautc7d9d392018-07-15 00:34:07 +02001189 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
Mark Lobodzinskib41e1652019-04-18 08:30:27 -06001190 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001191 }
1192
1193 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001194 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1195 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001196 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1197 if (binding_it != vertex_bindings.cend()) {
1198 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1199 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1200 "vkCreateGraphicsPipelines: parameter "
1201 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1202 "(%" PRIu32 ") is not distinct.",
1203 i, d, vertex_bind_desc.binding);
1204 }
1205 vertex_bindings.insert(vertex_bind_desc.binding);
1206
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001207 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001208 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06001209 "VUID-VkVertexInputBindingDescription-binding-00618",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001210 "vkCreateGraphicsPipelines: parameter "
1211 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001212 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001213 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001214 }
1215
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001216 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001217 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06001218 "VUID-VkVertexInputBindingDescription-stride-00619",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001219 "vkCreateGraphicsPipelines: parameter "
1220 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001221 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001222 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001223 }
1224 }
1225
Peter Kohautc7d9d392018-07-15 00:34:07 +02001226 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001227 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1228 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001229 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1230 if (location_it != attribute_locations.cend()) {
1231 skip |= log_msg(
1232 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1233 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
1234 "vkCreateGraphicsPipelines: parameter "
1235 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1236 i, d, vertex_attrib_desc.location);
1237 }
1238 attribute_locations.insert(vertex_attrib_desc.location);
1239
1240 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1241 if (binding_it == vertex_bindings.cend()) {
1242 skip |= log_msg(
1243 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1244 "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
1245 "vkCreateGraphicsPipelines: parameter "
1246 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1247 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1248 i, d, vertex_attrib_desc.binding, i);
1249 }
1250
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001251 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001252 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06001253 "VUID-VkVertexInputAttributeDescription-location-00620",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001254 "vkCreateGraphicsPipelines: parameter "
1255 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001256 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001257 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001258 }
1259
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001260 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001261 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06001262 "VUID-VkVertexInputAttributeDescription-binding-00621",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001263 "vkCreateGraphicsPipelines: parameter "
1264 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001265 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001266 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001267 }
1268
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001269 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06001270 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06001271 "VUID-VkVertexInputAttributeDescription-offset-00622",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001272 "vkCreateGraphicsPipelines: parameter "
1273 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1274 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001275 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001276 }
1277 }
1278 }
1279
1280 if (pCreateInfos[i].pStages != nullptr) {
1281 bool has_control = false;
1282 bool has_eval = false;
1283
1284 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1285 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1286 has_control = true;
1287 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1288 has_eval = true;
1289 }
1290 }
1291
1292 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1293 if (has_control && has_eval) {
1294 if (pCreateInfos[i].pTessellationState == nullptr) {
1295 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06001296 "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001297 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1298 "shader stage and a tessellation evaluation shader stage, "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001299 "pCreateInfos[%d].pTessellationState must not be NULL.",
1300 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001301 } else {
Lockee04009e2019-03-08 12:22:35 -07001302 const VkStructureType allowed_type =
1303 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001304 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001305 "vkCreateGraphicsPipelines",
Lockee04009e2019-03-08 12:22:35 -07001306 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1307 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1308 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001309
1310 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001311 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001312 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001313 pCreateInfos[i].pTessellationState->flags,
1314 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001315
1316 if (pCreateInfos[i].pTessellationState->sType !=
1317 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO) {
1318 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06001319 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001320 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pTessellationState->sType must "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001321 "be VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO.",
1322 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001323 }
1324
1325 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001326 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001327 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06001328 "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001329 "vkCreateGraphicsPipelines: invalid parameter "
1330 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001331 "should be >0 and <=%u.",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001332 i, pCreateInfos[i].pTessellationState->patchControlPoints,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001333 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001334 }
1335 }
1336 }
1337 }
1338
1339 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1340 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1341 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1342 if (pCreateInfos[i].pViewportState == nullptr) {
Petr Krausa6103552017-11-16 21:21:58 +01001343 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06001344 VK_NULL_HANDLE, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
Petr Krausa6103552017-11-16 21:21:58 +01001345 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1346 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001347 "].pViewportState (=NULL) is not a valid pointer.",
1348 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001349 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001350 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1351
1352 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
1353 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06001354 VK_NULL_HANDLE, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
Petr Krausa6103552017-11-16 21:21:58 +01001355 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001356 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1357 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001358 }
1359
Petr Krausa6103552017-11-16 21:21:58 +01001360 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1361 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001362 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1363 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001364 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1365 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001366 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001367 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001368 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001369 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001370 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001371 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1372 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001373 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
Dave Houlton413a6782018-05-22 13:01:54 -06001374 allowed_structs_VkPipelineViewportStateCreateInfo, 65,
1375 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001376
1377 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001378 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001379 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001380 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001381
Dave Houlton142c4cb2018-10-17 15:04:41 -06001382 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1383 pCreateInfos[i].pViewportState->pNext);
1384 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1385 pCreateInfos[i].pViewportState->pNext);
1386 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1387 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001388 const auto vp_swizzle_struct =
1389 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001390 const auto vp_w_scaling_struct =
1391 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001392
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001393 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001394 if (viewport_state.viewportCount != 1) {
1395 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06001396 VK_NULL_HANDLE, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
Petr Krausa6103552017-11-16 21:21:58 +01001397 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1398 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001399 ") is not 1.",
1400 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001401 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001402
Petr Krausa6103552017-11-16 21:21:58 +01001403 if (viewport_state.scissorCount != 1) {
1404 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06001405 VK_NULL_HANDLE, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
Petr Krausa6103552017-11-16 21:21:58 +01001406 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1407 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001408 ") is not 1.",
1409 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001410 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001411
Dave Houlton142c4cb2018-10-17 15:04:41 -06001412 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1413 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
1414 skip |=
1415 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1416 VK_NULL_HANDLE,
1417 "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1418 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1419 "disabled, but pCreateInfos[%" PRIu32
1420 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1421 ") is not 1.",
1422 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001423 }
1424
Jeff Bolz9af91c52018-09-01 21:53:57 -05001425 if (shading_rate_image_struct &&
1426 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
1427 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
Dave Houlton142c4cb2018-10-17 15:04:41 -06001428 VK_NULL_HANDLE,
1429 "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001430 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
Dave Houlton142c4cb2018-10-17 15:04:41 -06001431 "disabled, but pCreateInfos[%" PRIu32
1432 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001433 ") is neither 0 nor 1.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001434 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001435 }
1436
Petr Krausa6103552017-11-16 21:21:58 +01001437 } else { // multiViewport enabled
1438 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001439 skip |= log_msg(
1440 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06001441 VK_NULL_HANDLE, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001442 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001443 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Petr Krausa6103552017-11-16 21:21:58 +01001444 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06001445 VK_NULL_HANDLE, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
Petr Krausa6103552017-11-16 21:21:58 +01001446 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1447 "].pViewportState->viewportCount (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001448 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001449 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001450 }
Petr Krausa6103552017-11-16 21:21:58 +01001451
1452 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001453 skip |= log_msg(
1454 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06001455 VK_NULL_HANDLE, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001456 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001457 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Petr Krausa6103552017-11-16 21:21:58 +01001458 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06001459 VK_NULL_HANDLE, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
Petr Krausa6103552017-11-16 21:21:58 +01001460 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1461 "].pViewportState->scissorCount (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001462 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001463 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001464 }
1465 }
1466
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001467 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
1468 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1469 VK_NULL_HANDLE,
1470 "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1471 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1472 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1473 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001474 }
1475
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001476 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001477 skip |=
1478 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1479 VK_NULL_HANDLE, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1480 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1481 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1482 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001483 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001484 }
1485
Petr Krausa6103552017-11-16 21:21:58 +01001486 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001487 skip |=
1488 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06001489 VK_NULL_HANDLE, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001490 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1491 ") is not identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1492 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001493 }
1494
Dave Houlton142c4cb2018-10-17 15:04:41 -06001495 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001496 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001497 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1498 VK_NULL_HANDLE,
1499 "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1500 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1501 ") must be zero or identical to pCreateInfos[%" PRIu32
1502 "].pViewportState->viewportCount (=%" PRIu32 ").",
1503 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001504 }
1505
Dave Houlton142c4cb2018-10-17 15:04:41 -06001506 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001507 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001508 skip |= log_msg(
1509 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, VK_NULL_HANDLE,
1510 "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
1511 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1512 "] "
1513 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1514 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1515 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001516 }
1517
Petr Krausa6103552017-11-16 21:21:58 +01001518 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
1519 skip |= log_msg(
1520 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, VK_NULL_HANDLE,
Dave Houlton413a6782018-05-22 13:01:54 -06001521 "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001522 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1523 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001524 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1525 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001526 }
1527
1528 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
1529 skip |= log_msg(
1530 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, VK_NULL_HANDLE,
Dave Houlton413a6782018-05-22 13:01:54 -06001531 "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001532 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1533 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001534 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1535 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001536 }
1537
Jeff Bolz3e71f782018-08-29 23:15:45 -05001538 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001539 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1540 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1541 skip |=
1542 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1543 VK_NULL_HANDLE, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-pDynamicStates-02030",
1544 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1545 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1546 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1547 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001548 }
1549
Jeff Bolz9af91c52018-09-01 21:53:57 -05001550 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001551 shading_rate_image_struct->viewportCount > 0 &&
1552 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001553 skip |= log_msg(
1554 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, VK_NULL_HANDLE,
1555 "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-pDynamicStates-02057",
1556 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001557 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1558 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001559 i, i);
1560 }
1561
Chris Mayer328d8212018-12-11 14:16:18 +01001562 if (vp_swizzle_struct) {
1563 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
1564 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1565 VK_NULL_HANDLE, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
1566 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
1567 " does "
1568 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
1569 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
1570 }
1571 }
1572
Petr Krausb3fcdb42018-01-09 22:09:09 +01001573 // validate the VkViewports
1574 if (!has_dynamic_viewport && viewport_state.pViewports) {
1575 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
1576 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001577 const char *fn_name = "vkCreateGraphicsPipelines";
1578 skip |= manual_PreCallValidateViewport(viewport, fn_name,
1579 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
1580 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001581 VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001582 }
1583 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001584
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001585 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001586 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06001587 VK_NULL_HANDLE, kVUID_PVError_ExtensionNotEnabled,
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001588 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
Dave Houltona9df0ce2018-02-07 10:51:23 -07001589 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001590 "VK_NV_clip_space_w_scaling extension is not enabled.",
1591 i);
1592 }
1593
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001594 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001595 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06001596 VK_NULL_HANDLE, kVUID_PVError_ExtensionNotEnabled,
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001597 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
Dave Houltona9df0ce2018-02-07 10:51:23 -07001598 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001599 "VK_EXT_discard_rectangles extension is not enabled.",
1600 i);
1601 }
1602
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001603 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001604 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06001605 VK_NULL_HANDLE, kVUID_PVError_ExtensionNotEnabled,
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001606 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
Dave Houltona9df0ce2018-02-07 10:51:23 -07001607 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001608 "VK_EXT_sample_locations extension is not enabled.",
1609 i);
1610 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001611
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001612 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05001613 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1614 VK_NULL_HANDLE, kVUID_PVError_ExtensionNotEnabled,
1615 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1616 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
1617 "VK_NV_scissor_exclusive extension is not enabled.",
1618 i);
1619 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001620
1621 if (coarse_sample_order_struct &&
1622 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
1623 coarse_sample_order_struct->customSampleOrderCount != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001624 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1625 VK_NULL_HANDLE,
1626 "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
1627 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1628 "] "
1629 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
1630 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
1631 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001632 }
1633
1634 if (coarse_sample_order_struct) {
1635 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001636 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001637 }
1638 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001639
1640 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
1641 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
1642 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1643 VK_NULL_HANDLE, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
1644 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1645 "] "
1646 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
1647 ") "
1648 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
1649 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
1650 }
1651 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
1652 skip |= log_msg(
1653 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
1654 VK_NULL_HANDLE, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
1655 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1656 "] "
1657 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
1658 i);
1659 }
1660 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001661 }
1662
1663 if (pCreateInfos[i].pMultisampleState == nullptr) {
1664 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06001665 "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001666 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001667 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
1668 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001669 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07001670 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
1671 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
1672 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07001673 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07001674 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07001675 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001676 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001677 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07001678 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001679 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
1680 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001681
1682 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001683 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001684 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001685 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001686
1687 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001688 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001689 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
1690 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
1691
1692 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001693 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001694 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1695 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00001696 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06001697 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001698
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001699 skip |= validate_flags(
1700 "vkCreateGraphicsPipelines",
1701 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1702 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02001703 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001704
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001705 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001706 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001707 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
1708 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
1709
1710 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001711 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001712 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
1713 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
1714
1715 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
1716 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06001717 kVUID_PVError_InvalidStructSType,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001718 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
1719 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
1720 i);
1721 }
John Zulauf7acac592017-11-06 11:15:53 -07001722 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001723 if (!physical_device_features.sampleRateShading) {
John Zulauf7acac592017-11-06 11:15:53 -07001724 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06001725 "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
John Zulauf7acac592017-11-06 11:15:53 -07001726 "vkCreateGraphicsPipelines(): parameter "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001727 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
1728 i);
John Zulauf7acac592017-11-06 11:15:53 -07001729 }
1730 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
1731 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
1732 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
1733 skip |= log_msg(
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -06001734 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06001735 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001736 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07001737 }
1738 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001739
1740 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
1741 pCreateInfos[i].pRasterizationState->pNext);
1742
1743 if (line_state) {
1744 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
1745 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
1746 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
1747 skip |=
1748 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1749 "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1750 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1751 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
1752 i);
1753 }
1754 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
1755 skip |=
1756 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1757 "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1758 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1759 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
1760 i);
1761 }
1762 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
1763 skip |=
1764 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1765 "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1766 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1767 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
1768 i);
1769 }
1770 }
1771 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
1772 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
1773 skip |=
1774 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1775 "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
1776 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
1777 "range [1,256].",
1778 i, line_state->lineStippleFactor);
1779 }
1780 }
1781 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07001782 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001783 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1784 (!line_features || !line_features->rectangularLines)) {
1785 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1786 "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
1787 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1788 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
1789 i);
1790 }
1791 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1792 (!line_features || !line_features->bresenhamLines)) {
1793 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1794 "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
1795 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1796 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
1797 i);
1798 }
1799 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1800 (!line_features || !line_features->smoothLines)) {
1801 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
1802 "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
1803 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1804 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
1805 i);
1806 }
1807 if (line_state->stippledLineEnable) {
1808 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1809 (!line_features || !line_features->stippledRectangularLines)) {
1810 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT,
1811 0, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
1812 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1813 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
1814 "stippledRectangularLines feature.",
1815 i);
1816 }
1817 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1818 (!line_features || !line_features->stippledBresenhamLines)) {
1819 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT,
1820 0, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
1821 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1822 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
1823 "stippledBresenhamLines feature.",
1824 i);
1825 }
1826 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1827 (!line_features || !line_features->stippledSmoothLines)) {
1828 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT,
1829 0, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
1830 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1831 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
1832 "stippledSmoothLines feature.",
1833 i);
1834 }
1835 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
1836 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
1837 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT,
1838 0, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
1839 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1840 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
1841 "stippledRectangularLines and strictLines features.",
1842 i);
1843 }
1844 }
1845 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001846 }
1847
Petr Krause91f7a12017-12-14 20:57:36 +01001848 bool uses_color_attachment = false;
1849 bool uses_depthstencil_attachment = false;
1850 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07001851 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001852 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
1853 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01001854 const auto &subpasses_uses = subpasses_uses_it->second;
1855 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
1856 uses_color_attachment = true;
1857 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
1858 uses_depthstencil_attachment = true;
1859 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07001860 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01001861 }
1862
1863 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001864 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001865 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001866 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001867 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
Dave Houlton413a6782018-05-22 13:01:54 -06001868 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001869
1870 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001871 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001872 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001873 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001874
1875 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001876 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001877 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
1878 pCreateInfos[i].pDepthStencilState->depthTestEnable);
1879
1880 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001881 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001882 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
1883 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
1884
1885 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001886 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001887 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
1888 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001889 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001890
1891 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001892 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001893 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
1894 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
1895
1896 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001897 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001898 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
1899 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
1900
1901 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001902 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001903 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
1904 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001905 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001906
1907 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001908 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001909 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
1910 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001911 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001912
1913 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001914 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001915 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
1916 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001917 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001918
1919 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001920 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001921 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
1922 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001923 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001924
1925 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001926 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001927 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
1928 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001929 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001930
1931 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001932 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001933 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
1934 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001935 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001936
1937 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001938 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001939 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
1940 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001941 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001942
1943 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001944 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001945 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
1946 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001947 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001948
1949 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
1950 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06001951 kVUID_PVError_InvalidStructSType,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001952 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
1953 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
1954 i);
1955 }
1956 }
1957
Shannon McPherson9b9532b2018-10-24 12:00:09 -06001958 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
1959 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
1960
Petr Krause91f7a12017-12-14 20:57:36 +01001961 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001962 skip |= validate_struct_type("vkCreateGraphicsPipelines",
1963 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
1964 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
1965 pCreateInfos[i].pColorBlendState,
1966 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
1967 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
1968
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001969 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001970 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06001971 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
1972 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
1973 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001974 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
Dave Houlton413a6782018-05-22 13:01:54 -06001975 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001976
1977 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001978 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001979 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001980 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001981
1982 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001983 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001984 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
1985 pCreateInfos[i].pColorBlendState->logicOpEnable);
1986
1987 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001988 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001989 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
1990 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00001991 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06001992 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001993
1994 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
1995 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
1996 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001997 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001998 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
1999 ParameterName::IndexVector{i, attachmentIndex}),
2000 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2001
2002 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002003 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002004 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2005 ParameterName::IndexVector{i, attachmentIndex}),
2006 "VkBlendFactor", AllVkBlendFactorEnums,
2007 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002008 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002009
2010 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002011 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002012 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2013 ParameterName::IndexVector{i, attachmentIndex}),
2014 "VkBlendFactor", AllVkBlendFactorEnums,
2015 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002016 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002017
2018 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002019 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002020 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2021 ParameterName::IndexVector{i, attachmentIndex}),
2022 "VkBlendOp", AllVkBlendOpEnums,
2023 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002024 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002025
2026 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002027 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002028 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2029 ParameterName::IndexVector{i, attachmentIndex}),
2030 "VkBlendFactor", AllVkBlendFactorEnums,
2031 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002032 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002033
2034 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002035 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002036 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2037 ParameterName::IndexVector{i, attachmentIndex}),
2038 "VkBlendFactor", AllVkBlendFactorEnums,
2039 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002040 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002041
2042 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002043 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002044 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2045 ParameterName::IndexVector{i, attachmentIndex}),
2046 "VkBlendOp", AllVkBlendOpEnums,
2047 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002048 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002049
2050 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002051 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002052 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2053 ParameterName::IndexVector{i, attachmentIndex}),
2054 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2055 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002056 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002057 }
2058 }
2059
2060 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
2061 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002062 kVUID_PVError_InvalidStructSType,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002063 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2064 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2065 i);
2066 }
2067
2068 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2069 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2070 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002071 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002072 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002073 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2074 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002075 }
2076 }
2077 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002078
Petr Kraus9752aae2017-11-24 03:05:50 +01002079 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2080 if (pCreateInfos[i].basePipelineIndex != -1) {
2081 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Dave Houltona9df0ce2018-02-07 10:51:23 -07002082 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002083 "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
Dave Houltona9df0ce2018-02-07 10:51:23 -07002084 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineHandle, must be "
2085 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002086 "and pCreateInfos->basePipelineIndex is not -1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002087 }
2088 }
2089
Petr Kraus9752aae2017-11-24 03:05:50 +01002090 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2091 if (pCreateInfos[i].basePipelineIndex != -1) {
Dave Houltona9df0ce2018-02-07 10:51:23 -07002092 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002093 "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
Dave Houltona9df0ce2018-02-07 10:51:23 -07002094 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineIndex, must be -1 if "
2095 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002096 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002097 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002098 } else {
2099 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
2100 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2101 "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2102 "vkCreateGraphicsPipelines parameter pCreateInfos->basePipelineIndex (%d) must be a valid"
2103 "index into the pCreateInfos array, of size %d.",
2104 pCreateInfos[i].basePipelineIndex, createInfoCount);
2105 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002106 }
2107 }
2108
Petr Kraus9752aae2017-11-24 03:05:50 +01002109 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002110 if (!device_extensions.vk_nv_fill_rectangle) {
2111 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2112 skip |=
2113 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2114 "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
Dave Houltona9df0ce2018-02-07 10:51:23 -07002115 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
Chris Mayer840b2c42019-08-22 18:12:22 +02002116 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2117 "if the extension VK_NV_fill_rectangle is not enabled.");
2118 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2119 (physical_device_features.fillModeNonSolid == false)) {
2120 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2121 kVUID_PVError_DeviceFeature,
2122 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2123 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2124 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
2125 }
2126 } else {
2127 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2128 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2129 (physical_device_features.fillModeNonSolid == false)) {
2130 skip |=
2131 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2132 "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2133 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2134 "pCreateInfos->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2135 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
2136 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002137 }
Petr Kraus299ba622017-11-24 03:09:03 +01002138
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002139 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002140 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002141 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, 0,
2142 "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2143 "The line width state is static (pCreateInfos[%" PRIu32
2144 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2145 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2146 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2147 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002148 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002149 }
2150
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002151 for (size_t j = 0; j < pCreateInfos[i].stageCount; j++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002152 skip |= validate_string("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002153 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, j}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002154 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[j].pName);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002155 }
2156 }
2157 }
2158
2159 return skip;
2160}
2161
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002162bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2163 uint32_t createInfoCount,
2164 const VkComputePipelineCreateInfo *pCreateInfos,
2165 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002166 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002167 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002168 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002169 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002170 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002171 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002172 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2173 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
2174 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, VK_NULL_HANDLE,
2175 "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2176 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2177 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2178 i, feedback_struct->pipelineStageCreationFeedbackCount);
2179 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002180 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002181 return skip;
2182}
2183
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002184bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002185 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002186 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002187
2188 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002189 const auto &features = physical_device_features;
2190 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002191
John Zulauf71968502017-10-26 13:51:15 -06002192 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2193 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -06002194 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002195 "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002196 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
John Zulauf71968502017-10-26 13:51:15 -06002197 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002198 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002199 }
2200
2201 // Anistropy cannot be enabled in sampler unless enabled as a feature
2202 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -06002203 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002204 "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002205 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2206 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002207 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002208 }
John Zulauf71968502017-10-26 13:51:15 -06002209
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002210 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2211 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
2212 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2213 "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2214 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2215 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2216 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
2217 }
2218 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
2219 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2220 "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2221 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2222 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2223 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
2224 }
2225 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
2226 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2227 "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2228 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2229 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2230 pCreateInfo->minLod, pCreateInfo->maxLod);
2231 }
2232 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2233 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2234 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2235 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
2236 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2237 "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2238 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2239 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2240 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2241 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2242 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
2243 }
2244 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -06002245 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002246 "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
Dave Houltona9df0ce2018-02-07 10:51:23 -07002247 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002248 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002249 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002250 if (pCreateInfo->compareEnable == VK_TRUE) {
2251 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2252 "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2253 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2254 "not both be VK_TRUE.");
2255 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002256 }
2257
2258 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2259 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002260 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2261 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002262 }
2263
2264 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2265 // valid VkBorderColor value
2266 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2267 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2268 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002269 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2270 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002271 }
2272
2273 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2274 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002275 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002276 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2277 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2278 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002279 skip |=
2280 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2281 "VUID-VkSamplerCreateInfo-addressModeU-01079",
2282 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2283 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002284 }
John Zulauf275805c2017-10-26 15:34:49 -06002285
2286 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002287 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002288 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2289 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -06002290 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002291 "VUID-VkSamplerCreateInfo-magFilter-01081",
Dave Houltona9df0ce2018-02-07 10:51:23 -07002292 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002293 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002294 }
2295 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002296
2297 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2298 if (sampler_conversion != nullptr) {
2299 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2300 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2301 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2302 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
2303 skip |= log_msg(
2304 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2305 "VUID-VkSamplerCreateInfo-addressModeU-01646",
2306 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2307 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2308 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2309 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2310 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2311 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2312 }
2313 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002314 }
2315
2316 return skip;
2317}
2318
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002319bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2320 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2321 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002322 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002323 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002324
2325 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2326 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2327 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2328 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
2329 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER or VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, and descriptorCount
2330 // is not 0 and pImmutableSamplers is not NULL, pImmutableSamplers must be a pointer to an array of descriptorCount
2331 // valid VkSampler handles
2332 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2333 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2334 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2335 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2336 ++descriptor_index) {
2337 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
2338 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002339 kVUID_PVError_RequiredParameter,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002340 "vkCreateDescriptorSetLayout: required parameter "
Dave Houltona9df0ce2018-02-07 10:51:23 -07002341 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002342 i, descriptor_index);
2343 }
2344 }
2345 }
2346
2347 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2348 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2349 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Dave Houltona9df0ce2018-02-07 10:51:23 -07002350 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002351 "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
Dave Houltona9df0ce2018-02-07 10:51:23 -07002352 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2353 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002354 "values.",
2355 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002356 }
2357 }
2358 }
2359 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002360 return skip;
2361}
2362
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002363bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2364 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002365 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002366 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2367 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2368 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002369 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2370 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002371}
2372
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002373bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002374 const VkWriteDescriptorSet *pDescriptorWrites,
2375 uint32_t descriptorCopyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002376 const VkCopyDescriptorSet *pDescriptorCopies) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002377 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002378 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2379 if (pDescriptorWrites != NULL) {
2380 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2381 // descriptorCount must be greater than 0
2382 if (pDescriptorWrites[i].descriptorCount == 0) {
2383 skip |=
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -06002384 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002385 "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002386 "vkUpdateDescriptorSets(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002387 }
2388
2389 // dstSet must be a valid VkDescriptorSet handle
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002390 skip |= validate_required_handle("vkUpdateDescriptorSets",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002391 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2392 pDescriptorWrites[i].dstSet);
2393
2394 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2395 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2396 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2397 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2398 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2399 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2400 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2401 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures
2402 if (pDescriptorWrites[i].pImageInfo == nullptr) {
2403 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002404 "VUID-VkWriteDescriptorSet-descriptorType-00322",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002405 "vkUpdateDescriptorSets(): if pDescriptorWrites[%d].descriptorType is "
2406 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2407 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002408 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2409 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002410 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2411 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
2412 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageView and imageLayout
2413 // members of any given element of pImageInfo must be a valid VkImageView and VkImageLayout, respectively
2414 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2415 ++descriptor_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002416 skip |= validate_required_handle("vkUpdateDescriptorSets",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002417 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageView",
2418 ParameterName::IndexVector{i, descriptor_index}),
2419 pDescriptorWrites[i].pImageInfo[descriptor_index].imageView);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002420 skip |= validate_ranged_enum("vkUpdateDescriptorSets",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002421 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2422 ParameterName::IndexVector{i, descriptor_index}),
2423 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002424 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002425 }
2426 }
2427 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2428 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2429 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2430 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2431 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2432 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2433 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
2434 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
2435 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002436 "VUID-VkWriteDescriptorSet-descriptorType-00324",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002437 "vkUpdateDescriptorSets(): if pDescriptorWrites[%d].descriptorType is "
2438 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2439 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002440 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2441 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002442 } else {
2443 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount; ++descriptorIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002444 skip |= validate_required_handle("vkUpdateDescriptorSets",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002445 ParameterName("pDescriptorWrites[%i].pBufferInfo[%i].buffer",
2446 ParameterName::IndexVector{i, descriptorIndex}),
2447 pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer);
2448 }
2449 }
2450 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2451 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
2452 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
2453 // pTexelBufferView must be a pointer to an array of descriptorCount valid VkBufferView handles
2454 if (pDescriptorWrites[i].pTexelBufferView == nullptr) {
2455 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002456 "VUID-VkWriteDescriptorSet-descriptorType-00323",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002457 "vkUpdateDescriptorSets(): if pDescriptorWrites[%d].descriptorType is "
2458 "VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002459 "pDescriptorWrites[%d].pTexelBufferView must not be NULL.",
2460 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002461 } else {
2462 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2463 ++descriptor_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002464 skip |= validate_required_handle("vkUpdateDescriptorSets",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002465 ParameterName("pDescriptorWrites[%i].pTexelBufferView[%i]",
2466 ParameterName::IndexVector{i, descriptor_index}),
2467 pDescriptorWrites[i].pTexelBufferView[descriptor_index]);
2468 }
2469 }
2470 }
2471
2472 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2473 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002474 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002475 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2476 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2477 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002478 skip |=
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002479 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT,
2480 0, "VUID-VkWriteDescriptorSet-descriptorType-00327",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002481 "vkUpdateDescriptorSets(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2482 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2483 i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002484 }
2485 }
2486 }
2487 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2488 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002489 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002490 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2491 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2492 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002493 skip |=
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002494 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT,
2495 0, "VUID-VkWriteDescriptorSet-descriptorType-00328",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002496 "vkUpdateDescriptorSets(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2497 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2498 i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002499 }
2500 }
2501 }
2502 }
2503 }
2504 }
2505 return skip;
2506}
2507
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002508bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002509 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002510 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002511 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
2512}
2513
2514bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002515 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002516 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002517 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
2518}
2519
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002520bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
2521 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002522 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002523 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002524
2525 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2526 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2527 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002528 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
2529 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002530 return skip;
2531}
2532
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002533bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002534 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002535 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02002536
2537 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
2538 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002539 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
2540
Petr Krause7bb9e82019-08-11 21:34:43 +02002541 // Implicit VUs
2542 // validate only sType here; pointer has to be validated in core_validation
2543 const bool kNotRequired = false;
2544 const char *kNoVUID = nullptr;
2545 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
2546 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
2547 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002548
Petr Krause7bb9e82019-08-11 21:34:43 +02002549 if (pInfo) {
2550 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
2551 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
2552 skip |= validate_struct_pnext(
2553 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
2554 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
2555 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002556
Petr Krause7bb9e82019-08-11 21:34:43 +02002557 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002558
Petr Krause7bb9e82019-08-11 21:34:43 +02002559 // Explicit VUs
2560 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
2561 skip |= log_msg(
2562 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
2563 HandleToUint64(commandBuffer), "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
2564 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
2565 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002566 }
Petr Krause7bb9e82019-08-11 21:34:43 +02002567
2568 if (physical_device_features.inheritedQueries) {
2569 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002570 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06002571 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02002572 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02002573 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002574 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02002575 }
2576
2577 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02002578 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002579 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002580 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02002581 } else { // !pipelineStatisticsQuery
2582 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
2583 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002584 }
Petr Kraus139757b2019-08-15 17:19:33 +02002585
2586 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
2587 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002588 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02002589 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
2590 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
2591 skip |= log_msg(
2592 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
2593 HandleToUint64(commandBuffer),
2594 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
2595 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
2596 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
2597 }
2598 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002599 }
2600
2601 return skip;
2602}
2603
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002604bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002605 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002606 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002607
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002608 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01002609 if (firstViewport != 0) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002610 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06002611 HandleToUint64(commandBuffer), "VUID-vkCmdSetViewport-firstViewport-01224",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002612 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
2613 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01002614 }
2615 if (viewportCount > 1) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002616 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06002617 HandleToUint64(commandBuffer), "VUID-vkCmdSetViewport-viewportCount-01225",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002618 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
2619 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01002620 }
2621 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01002622 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002623 if (sum > device_limits.maxViewports) {
2624 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06002625 HandleToUint64(commandBuffer), "VUID-vkCmdSetViewport-firstViewport-01223",
Petr Krausd55e77c2018-01-09 22:09:25 +01002626 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002627 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002628 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002629 }
2630 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01002631
2632 if (pViewports) {
2633 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
2634 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002635 const char *fn_name = "vkCmdSetViewport";
2636 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2637 ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002638 VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(commandBuffer));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002639 }
2640 }
2641
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002642 return skip;
2643}
2644
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002645bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002646 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002647 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002648
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002649 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002650 if (firstScissor != 0) {
Petr Kraus6260f0a2018-02-27 21:15:55 +01002651 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06002652 HandleToUint64(commandBuffer), "VUID-vkCmdSetScissor-firstScissor-00593",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002653 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
2654 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002655 }
2656 if (scissorCount > 1) {
2657 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06002658 HandleToUint64(commandBuffer), "VUID-vkCmdSetScissor-scissorCount-00594",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002659 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
2660 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002661 }
2662 } else { // multiViewport enabled
2663 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002664 if (sum > device_limits.maxViewports) {
2665 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06002666 HandleToUint64(commandBuffer), "VUID-vkCmdSetScissor-firstScissor-00592",
Petr Kraus6260f0a2018-02-27 21:15:55 +01002667 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002668 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002669 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002670 }
2671 }
2672
Petr Kraus6260f0a2018-02-27 21:15:55 +01002673 if (pScissors) {
2674 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
2675 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002676
Petr Kraus6260f0a2018-02-27 21:15:55 +01002677 if (scissor.offset.x < 0) {
2678 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06002679 HandleToUint64(commandBuffer), "VUID-vkCmdSetScissor-x-00595",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002680 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
2681 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002682 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002683
Petr Kraus6260f0a2018-02-27 21:15:55 +01002684 if (scissor.offset.y < 0) {
2685 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06002686 HandleToUint64(commandBuffer), "VUID-vkCmdSetScissor-x-00595",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002687 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
2688 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002689 }
2690
2691 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2692 if (x_sum > INT32_MAX) {
2693 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06002694 HandleToUint64(commandBuffer), "VUID-vkCmdSetScissor-offset-00596",
Petr Kraus6260f0a2018-02-27 21:15:55 +01002695 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002696 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2697 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002698 }
2699
2700 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2701 if (y_sum > INT32_MAX) {
2702 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06002703 HandleToUint64(commandBuffer), "VUID-vkCmdSetScissor-offset-00597",
Petr Kraus6260f0a2018-02-27 21:15:55 +01002704 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002705 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2706 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002707 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002708 }
2709 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01002710
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002711 return skip;
2712}
2713
Jeff Bolz5c801d12019-10-09 10:38:45 -05002714bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01002715 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01002716
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002717 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Petr Kraus299ba622017-11-24 03:09:03 +01002718 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06002719 HandleToUint64(commandBuffer), "VUID-vkCmdSetLineWidth-lineWidth-00788",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002720 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002721 }
2722
2723 return skip;
2724}
2725
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002726bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002727 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002728 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002729 if (vertexCount == 0) {
2730 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
2731 // this an error or leave as is.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002732 skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002733 kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002734 }
2735
2736 if (instanceCount == 0) {
2737 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
2738 // this an error or leave as is.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002739 skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002740 kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002741 }
2742 return skip;
2743}
2744
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002745bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002746 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002747 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002748
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002749 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
2750 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002751 kVUID_PVError_DeviceFeature,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002752 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
2753 }
2754 return skip;
2755}
2756
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002757bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002758 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002759 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002760 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002761 skip |= log_msg(
2762 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, kVUID_PVError_DeviceFeature,
2763 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002764 }
2765 return skip;
2766}
2767
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002768bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
2769 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002770 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002771 bool skip = false;
2772 for (uint32_t rect = 0; rect < rectCount; rect++) {
2773 if (pRects[rect].layerCount == 0) {
2774 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
2775 HandleToUint64(commandBuffer), "VUID-vkCmdClearAttachments-layerCount-01934",
2776 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
2777 }
2778 }
2779 return skip;
2780}
2781
Andrew Fobel3abeb992020-01-20 16:33:22 -05002782bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
2783 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2784 VkImageFormatProperties2 *pImageFormatProperties,
2785 const char *apiName) const {
2786 bool skip = false;
2787
2788 if (pImageFormatInfo != nullptr) {
2789 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
2790 if (image_stencil_struct != nullptr) {
2791 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
2792 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
2793 // No flags other than the legal attachment bits may be set
2794 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
2795 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
2796 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0,
2797 "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
2798 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
2799 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
2800 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
2801 apiName);
2802 }
2803 }
2804 }
2805 }
2806
2807 return skip;
2808}
2809
2810bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
2811 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2812 VkImageFormatProperties2 *pImageFormatProperties) const {
2813 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
2814 "vkGetPhysicalDeviceImageFormatProperties2");
2815}
2816
2817bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
2818 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2819 VkImageFormatProperties2 *pImageFormatProperties) const {
2820 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
2821 "vkGetPhysicalDeviceImageFormatProperties2KHR");
2822}
2823
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002824bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
2825 VkImageLayout srcImageLayout, VkImage dstImage,
2826 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002827 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002828 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002829
Dave Houltonf5217612018-02-02 16:18:52 -07002830 VkImageAspectFlags legal_aspect_flags =
2831 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 -07002832 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002833 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2834 }
2835
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002836 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002837 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002838 skip |= log_msg(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002839 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002840 "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002841 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002842 }
Dave Houltonf5217612018-02-02 16:18:52 -07002843 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002844 skip |= log_msg(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002845 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002846 "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002847 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002848 }
2849 }
2850 return skip;
2851}
2852
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002853bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
2854 VkImageLayout srcImageLayout, VkImage dstImage,
2855 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002856 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002857 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002858
Dave Houltonf5217612018-02-02 16:18:52 -07002859 VkImageAspectFlags legal_aspect_flags =
2860 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 -07002861 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002862 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2863 }
2864
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002865 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002866 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002867 skip |= log_msg(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002868 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002869 kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002870 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
2871 }
Dave Houltonf5217612018-02-02 16:18:52 -07002872 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002873 skip |= log_msg(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002874 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002875 kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002876 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
2877 }
2878 }
2879 return skip;
2880}
2881
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002882bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
2883 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002884 uint32_t regionCount,
2885 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002886 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002887
Dave Houltonf5217612018-02-02 16:18:52 -07002888 VkImageAspectFlags legal_aspect_flags =
2889 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 -07002890 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002891 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2892 }
2893
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002894 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002895 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002896 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002897 kVUID_PVError_UnrecognizedValue,
Dave Houltona9df0ce2018-02-07 10:51:23 -07002898 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
2899 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002900 }
2901 }
2902 return skip;
2903}
2904
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002905bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
2906 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002907 uint32_t regionCount,
2908 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002909 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002910
Dave Houltonf5217612018-02-02 16:18:52 -07002911 VkImageAspectFlags legal_aspect_flags =
2912 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 -07002913 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002914 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2915 }
2916
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002917 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002918 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002919 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002920 kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002921 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
2922 "enumerator");
2923 }
2924 }
2925 return skip;
2926}
2927
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002928bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002929 VkDeviceSize dstOffset, VkDeviceSize dataSize,
2930 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002931 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002932
2933 if (dstOffset & 3) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002934 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002935 "VUID-vkCmdUpdateBuffer-dstOffset-00036",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002936 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
2937 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002938 }
2939
2940 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002941 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002942 "VUID-vkCmdUpdateBuffer-dataSize-00037",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002943 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002944 "), must be greater than zero and less than or equal to 65536.",
2945 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002946 } else if (dataSize & 3) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002947 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002948 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002949 "VUID-vkCmdUpdateBuffer-dataSize-00038",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002950 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.", dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002951 }
2952 return skip;
2953}
2954
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002955bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002956 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002957 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002958
2959 if (dstOffset & 3) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002960 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002961 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002962 "VUID-vkCmdFillBuffer-dstOffset-00025",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002963 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002964 }
2965
2966 if (size != VK_WHOLE_SIZE) {
2967 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002968 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002969 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002970 "VUID-vkCmdFillBuffer-size-00026",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002971 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002972 } else if (size & 3) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002973 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002974 "VUID-vkCmdFillBuffer-size-00028",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002975 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002976 }
2977 }
2978 return skip;
2979}
2980
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002981bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002982 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002983 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002984 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002985
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002986 const LogMiscParams log_misc{VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, VK_NULL_HANDLE, "vkCreateSwapchainKHR"};
Petr Krause5c37652018-01-05 04:05:12 +01002987
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002988 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002989 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2990 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
2991 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
2992 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -06002993 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06002994 "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002995 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002996 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002997 }
2998
2999 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3000 // queueFamilyIndexCount uint32_t values
3001 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinskib1fd9d12018-03-30 14:26:00 -06003002 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06003003 "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003004 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3005 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003006 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003007 }
3008 }
3009
Dave Houlton413a6782018-05-22 13:01:54 -06003010 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
3011 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", log_misc);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003012 }
3013
3014 return skip;
3015}
3016
Jeff Bolz5c801d12019-10-09 10:38:45 -05003017bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003018 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003019
3020 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003021 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3022 if (present_regions) {
3023 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003024 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003025 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3026 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003027 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06003028 kVUID_PVError_InvalidUsage,
Dave Houltona9df0ce2018-02-07 10:51:23 -07003029 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3030 "extension swapchainCount is %i. These values must be equal.",
John Zulaufde972ac2017-10-26 12:07:05 -06003031 pPresentInfo->swapchainCount, present_regions->swapchainCount);
3032 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003033 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
3034 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext");
3035 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3036 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3037 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003038 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003039 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003040 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003041 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003042 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003043 }
3044 }
3045
3046 return skip;
3047}
3048
3049#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003050bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3051 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3052 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003053 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003054 bool skip = false;
3055
3056 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003057 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
Dave Houlton413a6782018-05-22 13:01:54 -06003058 "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3059 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003060 }
3061
3062 return skip;
3063}
3064#endif // VK_USE_PLATFORM_WIN32_KHR
3065
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003066bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003067 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003068 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003069 bool skip = false;
3070
3071 if (pCreateInfo) {
3072 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003073 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT,
3074 VK_NULL_HANDLE, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3075 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003076 }
3077
3078 if (pCreateInfo->pPoolSizes) {
3079 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3080 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
3081 skip |= log_msg(
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003082 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, VK_NULL_HANDLE,
3083 "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003084 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003085 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003086 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3087 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003088 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT,
3089 VK_NULL_HANDLE, "VUID-VkDescriptorPoolSize-type-02218",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003090 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3091 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3092 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3093 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003094 }
Petr Krausc8655be2017-09-27 18:56:51 +02003095 }
3096 }
3097 }
3098
3099 return skip;
3100}
3101
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003102bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003103 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003104 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003105
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003106 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003107 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003108 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06003109 HandleToUint64(commandBuffer), "VUID-vkCmdDispatch-groupCountX-00386",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003110 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003111 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003112 }
3113
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003114 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003115 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003116 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06003117 HandleToUint64(commandBuffer), "VUID-vkCmdDispatch-groupCountY-00387",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003118 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003119 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003120 }
3121
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003122 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003123 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003124 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06003125 HandleToUint64(commandBuffer), "VUID-vkCmdDispatch-groupCountZ-00388",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003126 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003127 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003128 }
3129
3130 return skip;
3131}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003132
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003133bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003134 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003135 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003136
3137 if ((offset % 4) != 0) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003138 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Shannon McPhersonde3eeba2019-04-30 16:53:59 -06003139 HandleToUint64(commandBuffer), "VUID-vkCmdDispatchIndirect-offset-02710",
John Zulaufa999d1b2018-11-29 13:38:40 -07003140 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
3141 }
3142 return skip;
3143}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003144
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003145bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3146 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003147 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003148 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003149
3150 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003151 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003152 if (baseGroupX >= limit) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003153 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06003154 HandleToUint64(commandBuffer), "VUID-vkCmdDispatchBase-baseGroupX-00421",
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003155 "vkCmdDispatch(): baseGroupX (%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003156 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3157 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003158 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003159 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06003160 HandleToUint64(commandBuffer), "VUID-vkCmdDispatchBase-groupCountX-00424",
Mark Lobodzinskibf973a12018-03-01 08:50:21 -07003161 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003162 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3163 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003164 }
3165
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003166 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003167 if (baseGroupY >= limit) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003168 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06003169 HandleToUint64(commandBuffer), "VUID-vkCmdDispatchBase-baseGroupX-00422",
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003170 "vkCmdDispatch(): baseGroupY (%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003171 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3172 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003173 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003174 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06003175 HandleToUint64(commandBuffer), "VUID-vkCmdDispatchBase-groupCountY-00425",
Mark Lobodzinskibf973a12018-03-01 08:50:21 -07003176 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003177 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3178 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003179 }
3180
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003181 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003182 if (baseGroupZ >= limit) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003183 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06003184 HandleToUint64(commandBuffer), "VUID-vkCmdDispatchBase-baseGroupZ-00423",
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003185 "vkCmdDispatch(): baseGroupZ (%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003186 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3187 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003188 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003189 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton413a6782018-05-22 13:01:54 -06003190 HandleToUint64(commandBuffer), "VUID-vkCmdDispatchBase-groupCountZ-00426",
Mark Lobodzinskibf973a12018-03-01 08:50:21 -07003191 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003192 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3193 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003194 }
3195
3196 return skip;
3197}
3198
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003199bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3200 uint32_t firstExclusiveScissor,
3201 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003202 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003203 bool skip = false;
3204
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003205 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003206 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003207 skip |=
3208 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
3209 HandleToUint64(commandBuffer), "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3210 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3211 ") is not 0.",
3212 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003213 }
3214 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003215 skip |=
3216 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
3217 HandleToUint64(commandBuffer), "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3218 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3219 ") is not 1.",
3220 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003221 }
3222 } else { // multiViewport enabled
3223 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003224 if (sum > device_limits.maxViewports) {
3225 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Jeff Bolz3e71f782018-08-29 23:15:45 -05003226 HandleToUint64(commandBuffer), "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003227 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3228 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003229 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003230 }
3231 }
3232
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003233 if (firstExclusiveScissor >= device_limits.maxViewports) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003234 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
3235 HandleToUint64(commandBuffer), "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003236 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32
3237 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003238 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003239 }
3240
3241 if (pExclusiveScissors) {
3242 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3243 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3244
3245 if (scissor.offset.x < 0) {
3246 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
3247 HandleToUint64(commandBuffer), "VUID-vkCmdSetExclusiveScissorNV-x-02037",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003248 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3249 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003250 }
3251
3252 if (scissor.offset.y < 0) {
3253 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
3254 HandleToUint64(commandBuffer), "VUID-vkCmdSetExclusiveScissorNV-x-02037",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003255 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3256 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003257 }
3258
3259 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3260 if (x_sum > INT32_MAX) {
3261 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
3262 HandleToUint64(commandBuffer), "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3263 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3264 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3265 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
3266 }
3267
3268 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3269 if (y_sum > INT32_MAX) {
3270 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
3271 HandleToUint64(commandBuffer), "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3272 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3273 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3274 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
3275 }
3276 }
3277 }
3278
3279 return skip;
3280}
3281
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003282bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3283 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003284 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003285 bool skip = false;
3286 if (firstViewport >= device_limits.maxViewports) {
3287 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
3288 HandleToUint64(commandBuffer), "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3289 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3290 firstViewport, device_limits.maxViewports);
3291 } else {
3292 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3293 if ((sum < 1) || (sum > device_limits.maxViewports)) {
3294 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
3295 HandleToUint64(commandBuffer), "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3296 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3297 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3298 firstViewport, viewportCount, sum, device_limits.maxViewports);
3299 }
3300 }
3301
3302 return skip;
3303}
3304
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003305bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3306 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003307 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003308 bool skip = false;
3309
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003310 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003311 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003312 skip |=
3313 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
3314 HandleToUint64(commandBuffer), "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3315 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3316 ") is not 0.",
3317 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003318 }
3319 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003320 skip |=
3321 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
3322 HandleToUint64(commandBuffer), "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3323 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3324 ") is not 1.",
3325 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003326 }
3327 }
3328
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003329 if (firstViewport >= device_limits.maxViewports) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003330 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
3331 HandleToUint64(commandBuffer), "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003332 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3333 ") must be less than maxViewports (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003334 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003335 }
3336
3337 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003338 if (sum > device_limits.maxViewports) {
3339 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Jeff Bolz9af91c52018-09-01 21:53:57 -05003340 HandleToUint64(commandBuffer), "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3341 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3342 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003343 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003344 }
3345
3346 return skip;
3347}
3348
Jeff Bolz5c801d12019-10-09 10:38:45 -05003349bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3350 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3351 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003352 bool skip = false;
3353
Dave Houlton142c4cb2018-10-17 15:04:41 -06003354 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003355 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
3356 HandleToUint64(commandBuffer), "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3357 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3358 "customSampleOrderCount must be 0.");
3359 }
3360
3361 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003362 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003363 }
3364
3365 return skip;
3366}
3367
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003368bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003369 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003370 bool skip = false;
3371
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003372 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003373 skip |= log_msg(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003374 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Dave Houlton142c4cb2018-10-17 15:04:41 -06003375 HandleToUint64(commandBuffer), "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
3376 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3377 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003378 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003379 }
3380
3381 return skip;
3382}
3383
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003384bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3385 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003386 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003387 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003388 static const int condition_multiples = 0b0011;
3389 if (offset & condition_multiples) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003390 skip |= log_msg(
3391 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Shannon McPhersonde3eeba2019-04-30 16:53:59 -06003392 HandleToUint64(commandBuffer), "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003393 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003394 }
Lockee1c22882019-06-10 16:02:54 -06003395 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
3396 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
3397 HandleToUint64(commandBuffer), "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3398 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3399 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3400 stride);
3401 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003402 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Jeff Bolzb574c342018-11-08 15:36:57 -06003403 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Shannon McPhersonde3eeba2019-04-30 16:53:59 -06003404 HandleToUint64(commandBuffer), "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
Jeff Bolzb574c342018-11-08 15:36:57 -06003405 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
3406 drawCount);
3407 }
3408
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003409 return skip;
3410}
3411
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003412bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3413 VkDeviceSize offset, VkBuffer countBuffer,
3414 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003415 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003416 bool skip = false;
3417
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003418 if (offset & 3) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003419 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Shannon McPhersonde3eeba2019-04-30 16:53:59 -06003420 HandleToUint64(commandBuffer), "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003421 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3422 "), is not a multiple of 4.",
3423 offset);
3424 }
3425
3426 if (countBufferOffset & 3) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003427 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
Shannon McPhersonde3eeba2019-04-30 16:53:59 -06003428 HandleToUint64(commandBuffer), "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003429 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3430 "), is not a multiple of 4.",
3431 countBufferOffset);
3432 }
3433
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003434 return skip;
3435}
3436
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003437bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003438 const VkAllocationCallbacks *pAllocator,
3439 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003440 bool skip = false;
3441
3442 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3443 if (pCreateInfo != nullptr) {
3444 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3445 // VkQueryPipelineStatisticFlagBits values
3446 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3447 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
3448 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
3449 "VUID-VkQueryPoolCreateInfo-queryType-00792",
3450 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3451 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3452 "values.");
3453 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003454 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003455 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003456}
3457
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003458bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3459 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003460 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003461 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3462 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003463}
3464
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003465void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003466 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3467 VkResult result) {
3468 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003469 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003470}
3471
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003472void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003473 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3474 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003475 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003476 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003477 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003478}
3479
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003480void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
3481 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003482 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003483 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003484 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003485}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003486
3487bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003488 const VkAllocationCallbacks *pAllocator,
3489 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003490 bool skip = false;
3491
3492 if (pAllocateInfo) {
3493 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
3494 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
3495 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
3496 "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
3497 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
3498 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003499
3500 VkMemoryAllocateFlags flags = 0;
3501 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
3502 if (flags_info) {
3503 flags = flags_info->flags;
3504 }
3505
3506 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
3507 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
3508 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
3509 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
3510 "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
3511 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
3512 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
3513 }
3514
3515#ifdef VK_USE_PLATFORM_WIN32_KHR
3516 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
3517#endif
3518 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
3519 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
3520#ifdef VK_USE_PLATFORM_ANDROID_KHR
3521 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
3522#endif
3523
3524 if (import_memory_host_pointer) {
3525 skip |= log_msg(
3526 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
3527 "VUID-VkMemoryAllocateInfo-pNext-03332",
3528 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
3529 }
3530 if (
3531#ifdef VK_USE_PLATFORM_WIN32_KHR
3532 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
3533#endif
3534 (import_memory_fd && import_memory_fd->handleType) ||
3535#ifdef VK_USE_PLATFORM_ANDROID_KHR
3536 (import_memory_ahb && import_memory_ahb->buffer) ||
3537#endif
3538 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
3539 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
3540 "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
3541 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
3542 }
3543 }
3544
3545 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003546 VkBool32 capture_replay = false;
3547 VkBool32 buffer_device_address = false;
3548 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
3549 if (vulkan_12_features) {
3550 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
3551 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
3552 } else {
3553 const auto *bda_features =
3554 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
3555 if (bda_features) {
3556 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
3557 buffer_device_address = bda_features->bufferDeviceAddress;
3558 }
3559 }
3560 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003561 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
3562 "VUID-VkMemoryAllocateInfo-flags-03330",
3563 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
3564 "bufferDeviceAddressCaptureReplay must be enabled.");
3565 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003566 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003567 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
3568 "VUID-VkMemoryAllocateInfo-flags-03331",
3569 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
3570 }
3571 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003572 }
3573 return skip;
3574}
Ricardo Garciaa4935972019-02-21 17:43:18 +01003575
Jason Macnak192fa0e2019-07-26 15:07:16 -07003576bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
3577 VkDebugReportObjectTypeEXT object_type, uint64_t object_handle,
3578 const char *func_name) const {
3579 bool skip = false;
3580
3581 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
3582 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
3583 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
3584 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object_handle,
3585 "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
3586 } else {
3587 uint32_t vertex_component_size = 0;
3588 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
3589 vertex_component_size = 4;
3590 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
3591 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
3592 vertex_component_size = 2;
3593 }
3594 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
3595 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object_handle,
3596 "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
3597 }
3598 }
3599
3600 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
3601 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
3602 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object_handle,
3603 "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
3604 } else {
3605 uint32_t index_element_size = 0;
3606 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
3607 index_element_size = 4;
3608 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
3609 index_element_size = 2;
3610 }
3611 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
3612 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object_handle,
3613 "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
3614 }
3615 }
3616 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
3617 if (triangles.indexCount != 0) {
3618 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object_handle,
3619 "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
3620 }
3621 if (triangles.indexData != VK_NULL_HANDLE) {
3622 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object_handle,
3623 "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
3624 }
3625 }
3626
3627 if (SafeModulo(triangles.transformOffset, 16) != 0) {
3628 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object_handle,
3629 "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
3630 }
3631
3632 return skip;
3633}
3634
3635bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkDebugReportObjectTypeEXT object_type,
3636 uint64_t object_handle, const char *func_name) const {
3637 bool skip = false;
3638
3639 if (SafeModulo(aabbs.offset, 8) != 0) {
3640 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object_handle,
3641 "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
3642 }
3643 if (SafeModulo(aabbs.stride, 8) != 0) {
3644 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object_handle,
3645 "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
3646 }
3647
3648 return skip;
3649}
3650
3651bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkDebugReportObjectTypeEXT object_type,
3652 uint64_t object_handle, const char *func_name) const {
3653 bool skip = false;
3654 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
3655 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_type, object_handle, func_name);
3656 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
3657 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_type, object_handle, func_name);
3658 }
3659 return skip;
3660}
3661
3662bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
3663 VkDebugReportObjectTypeEXT object_type, uint64_t object_handle,
3664 const char *func_name) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003665 bool skip = false;
3666 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003667 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object_handle,
Jason Macnak5c954952019-07-09 15:46:12 -07003668 "VUID-VkAccelerationStructureInfoNV-type-02425",
3669 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
3670 "geometryCount must be 0.");
3671 }
3672 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003673 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object_handle,
Jason Macnak5c954952019-07-09 15:46:12 -07003674 "VUID-VkAccelerationStructureInfoNV-type-02426",
3675 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
3676 "instanceCount must be 0.");
3677 }
3678 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
3679 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003680 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object_handle,
Jason Macnak5c954952019-07-09 15:46:12 -07003681 "VUID-VkAccelerationStructureInfoNV-flags-02592",
3682 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
3683 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV bit set.");
3684 }
3685 if (info.geometryCount > phys_dev_ext_props.ray_tracing_props.maxGeometryCount) {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003686 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object_handle,
Jason Macnak5c954952019-07-09 15:46:12 -07003687 "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
3688 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
3689 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
3690 }
3691 if (info.instanceCount > phys_dev_ext_props.ray_tracing_props.maxInstanceCount) {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003692 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object_handle,
Jason Macnak5c954952019-07-09 15:46:12 -07003693 "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
3694 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
3695 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
3696 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003697 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07003698 uint64_t total_triangle_count = 0;
3699 for (uint32_t i = 0; i < info.geometryCount; i++) {
3700 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07003701
3702 skip |= ValidateGeometryNV(geometry, object_type, object_handle, func_name);
3703
Jason Macnak5c954952019-07-09 15:46:12 -07003704 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
3705 continue;
3706 }
3707 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
3708 }
3709 if (total_triangle_count > phys_dev_ext_props.ray_tracing_props.maxTriangleCount) {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003710 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object_handle,
3711 "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
Jason Macnak5c954952019-07-09 15:46:12 -07003712 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
3713 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
3714 }
3715 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003716 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
3717 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
3718 for (uint32_t i = 1; i < info.geometryCount; i++) {
3719 const VkGeometryNV &geometry = info.pGeometries[i];
3720 if (geometry.geometryType != first_geometry_type) {
3721 // TODO: update fake VUID below with the real one once it is generated.
3722 skip |=
3723 log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_ACCELERATION_STRUCTURE_NV_EXT,
3724 0, "UNASSIGNED-VkAccelerationStructureInfoNV-pGeometries-XXXX",
3725 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
3726 "info.pGeometries[0].geometryType.",
3727 i);
3728 }
3729 }
3730 }
Jason Macnak5c954952019-07-09 15:46:12 -07003731 return skip;
3732}
3733
Ricardo Garciaa4935972019-02-21 17:43:18 +01003734bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
3735 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003736 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01003737 bool skip = false;
3738
3739 if (pCreateInfo) {
3740 if ((pCreateInfo->compactedSize != 0) &&
3741 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
3742 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
3743 "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
3744 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
3745 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
3746 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
3747 }
Jason Macnak5c954952019-07-09 15:46:12 -07003748
Jason Macnak192fa0e2019-07-26 15:07:16 -07003749 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VK_DEBUG_REPORT_OBJECT_TYPE_ACCELERATION_STRUCTURE_NV_EXT, 0,
3750 "vkCreateAccelerationStructureNV()");
Ricardo Garciaa4935972019-02-21 17:43:18 +01003751 }
3752
3753 return skip;
3754}
Mike Schuchardt21638df2019-03-16 10:52:02 -07003755
Jeff Bolz5c801d12019-10-09 10:38:45 -05003756bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
3757 const VkAccelerationStructureInfoNV *pInfo,
3758 VkBuffer instanceData, VkDeviceSize instanceOffset,
3759 VkBool32 update, VkAccelerationStructureNV dst,
3760 VkAccelerationStructureNV src, VkBuffer scratch,
3761 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003762 bool skip = false;
3763
3764 if (pInfo != nullptr) {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003765 skip |= ValidateAccelerationStructureInfoNV(*pInfo, VK_DEBUG_REPORT_OBJECT_TYPE_ACCELERATION_STRUCTURE_NV_EXT,
3766 HandleToUint64(dst), "vkCmdBuildAccelerationStructureNV()");
Jason Macnak5c954952019-07-09 15:46:12 -07003767 }
3768
3769 return skip;
3770}
3771
3772bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
3773 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003774 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003775 bool skip = false;
3776 if (dataSize < 8) {
3777 skip = log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_ACCELERATION_STRUCTURE_NV_EXT,
3778 HandleToUint64(accelerationStructure), "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
3779 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
3780 }
3781 return skip;
3782}
3783
Peter Chen85366392019-05-14 15:20:11 -04003784bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
3785 uint32_t createInfoCount,
3786 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
3787 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003788 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04003789 bool skip = false;
3790
3791 for (uint32_t i = 0; i < createInfoCount; i++) {
3792 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
3793 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
3794 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, VK_NULL_HANDLE,
3795 "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
3796 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
3797 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
3798 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
3799 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
3800 }
3801 }
3802
3803 return skip;
3804}
3805
Mike Schuchardt21638df2019-03-16 10:52:02 -07003806#ifdef VK_USE_PLATFORM_WIN32_KHR
3807bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
3808 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003809 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07003810 bool skip = false;
3811 if (!device_extensions.vk_khr_swapchain)
3812 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
3813 if (!device_extensions.vk_khr_get_surface_capabilities_2)
3814 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
3815 if (!device_extensions.vk_khr_surface)
3816 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
3817 if (!device_extensions.vk_khr_get_physical_device_properties_2)
3818 skip |=
3819 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
3820 if (!device_extensions.vk_ext_full_screen_exclusive)
3821 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
3822 skip |= validate_struct_type(
3823 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
3824 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
3825 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
3826 if (pSurfaceInfo != NULL) {
3827 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
3828 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
3829 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
3830
3831 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
3832 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
3833 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
3834 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
3835 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext");
3836
3837 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
3838 }
3839 return skip;
3840}
3841#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01003842
3843bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
3844 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003845 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01003846 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3847 bool skip = false;
3848 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
3849 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
3850 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
3851 }
3852 return skip;
3853}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003854
3855bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003856 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003857 bool skip = false;
3858
3859 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
3860 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
3861 HandleToUint64(commandBuffer), "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
3862 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
3863 }
3864
3865 return skip;
3866}
Piers Daniell8fd03f52019-08-21 12:07:53 -06003867
3868bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003869 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06003870 bool skip = false;
3871
3872 if (indexType == VK_INDEX_TYPE_NONE_NV) {
3873 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
3874 HandleToUint64(commandBuffer), "VUID-vkCmdBindIndexBuffer-indexType-02507",
3875 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
3876 }
3877
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003878 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Piers Daniell8fd03f52019-08-21 12:07:53 -06003879 if (indexType == VK_INDEX_TYPE_UINT8_EXT && !index_type_uint8_features->indexTypeUint8) {
3880 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
3881 HandleToUint64(commandBuffer), "VUID-vkCmdBindIndexBuffer-indexType-02765",
3882 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
3883 }
3884
3885 return skip;
3886}
Mark Lobodzinski84988402019-09-11 15:27:30 -06003887
3888bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003889 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06003890 bool skip = false;
3891 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
3892 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, HandleToUint64(device),
3893 "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
3894 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
3895 }
3896 return skip;
3897}
3898
3899bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003900 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06003901 bool skip = false;
3902 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
3903 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, HandleToUint64(device),
3904 "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
3905 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
3906 }
3907 return skip;
3908}
Petr Kraus3d720392019-11-13 02:52:39 +01003909
3910bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
3911 VkSemaphore semaphore, VkFence fence,
3912 uint32_t *pImageIndex) const {
3913 bool skip = false;
3914
3915 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
3916 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT,
3917 HandleToUint64(swapchain), "VUID-vkAcquireNextImageKHR-semaphore-01780",
3918 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
3919 }
3920
3921 return skip;
3922}
3923
3924bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
3925 uint32_t *pImageIndex) const {
3926 bool skip = false;
3927
3928 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
3929 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT,
3930 HandleToUint64(pAcquireInfo->swapchain), "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
3931 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
3932 }
3933
3934 return skip;
3935}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07003936
3937bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
3938 uint32_t firstInstance, VkBuffer counterBuffer,
3939 VkDeviceSize counterBufferOffset,
3940 uint32_t counterOffset, uint32_t vertexStride) const {
3941 bool skip = false;
3942
3943 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
3944 skip |= log_msg(
3945 report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, HandleToUint64(counterBuffer),
3946 "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
3947 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
3948 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
3949 }
3950
3951 return skip;
3952}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08003953
3954bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
3955 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
3956 const VkAllocationCallbacks *pAllocator,
3957 VkSamplerYcbcrConversion *pYcbcrConversion,
3958 const char *apiName) const {
3959 bool skip = false;
3960
3961 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003962 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08003963 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
3964 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
3965 "VUID-vkCreateSamplerYcbcrConversion-None-01648", "samplerYcbcrConversion must be enabled to call %s.",
3966 apiName);
3967 }
3968 return skip;
3969}
3970
3971bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
3972 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
3973 const VkAllocationCallbacks *pAllocator,
3974 VkSamplerYcbcrConversion *pYcbcrConversion) const {
3975 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
3976 "vkCreateSamplerYcbcrConversion");
3977}
3978
3979bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
3980 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
3981 VkSamplerYcbcrConversion *pYcbcrConversion) const {
3982 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
3983 "vkCreateSamplerYcbcrConversionKHR");
3984}