blob: a099834a0c73567694c75808a171a7d0dee93a4f [file] [log] [blame]
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08001/* Copyright (c) 2015-2020 The Khronos Group Inc.
2 * Copyright (c) 2015-2020 Valve Corporation
3 * Copyright (c) 2015-2020 LunarG, Inc.
4 * Copyright (C) 2015-2020 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Mark Lobodzinskid4950072017-08-01 13:02:20 -060028static const int MaxParamCheckerStringLength = 256;
29
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070036bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050037 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060038 bool skip = false;
39
40 VkStringErrorFlags result = vk_string_validate(MaxParamCheckerStringLength, validateString);
41
42 if (result == VK_STRING_ERROR_NONE) {
43 return skip;
44 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070045 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
46 MaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060047 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070048 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
49 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060050 }
51 return skip;
52}
53
Jeff Bolz46c0ea02019-10-09 13:06:29 -050054bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060055 bool skip = false;
56 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
57 if (api_version_nopatch != effective_api_version) {
58 if (api_version_nopatch < VK_API_VERSION_1_0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070059 skip |= LogError(instance, kVUIDUndefined,
60 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
61 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
62 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060063 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070064 skip |= LogWarning(instance, kVUIDUndefined,
65 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
66 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
67 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060068 }
69 }
70 return skip;
71}
72
Jeff Bolz46c0ea02019-10-09 13:06:29 -050073bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060074 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060075 // Create and use a local instance extension object, as an actual instance has not been created yet
76 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
77 InstanceExtensions local_instance_extensions;
78 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
79
John Zulauf620755c2018-04-16 11:00:43 -060080 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060081 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
82 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060083 }
84
85 return skip;
86}
87
John Zulauf620755c2018-04-16 11:00:43 -060088template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -070089ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
90 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -060091 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -070092 ExtEnabled state =
93 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -060094 return state;
95}
96
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070097bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -050098 const VkAllocationCallbacks *pAllocator,
99 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700100 bool skip = false;
101 // Note: From the spec--
102 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
103 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
104 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700105 ? pCreateInfo->pApplicationInfo->apiVersion
106 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700107 skip |= validate_api_version(local_api_version, api_version);
108 skip |= validate_instance_extensions(pCreateInfo);
109 return skip;
110}
111
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700112void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700113 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
114 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700115 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
116 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700117 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700118 this->instance_extensions = instance_data->instance_extensions;
119}
120
locke-lunargb1909cd2019-08-01 23:40:05 -0600121void StatelessValidation::PostCallRecordQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo, VkResult result) {
122 for (uint32_t i = 0; i < pPresentInfo->swapchainCount; ++i) {
123 auto swapchains_result = pPresentInfo->pResults ? pPresentInfo->pResults[i] : result;
124 if (swapchains_result == VK_SUBOPTIMAL_KHR) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700125 LogPerformanceWarning(
126 pPresentInfo->pSwapchains[i], kVUID_PVPerfWarn_SuboptimalSwapchain,
127 "vkQueuePresentKHR: %s :VK_SUBOPTIMAL_KHR was returned. VK_SUBOPTIMAL_KHR - Presentation will still succeed, "
128 "subject to the window resize behavior, but the swapchain is no longer configured optimally for the surface it "
129 "targets. Applications should query updated surface information and recreate their swapchain at the next "
130 "convenient opportunity.",
131 report_data->FormatHandle(pPresentInfo->pSwapchains[i]).c_str());
locke-lunargb1909cd2019-08-01 23:40:05 -0600132 }
133 }
134}
135
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700136void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700137 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700138 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700139 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700140 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
141 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700142
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700143 // Parmeter validation also uses extension data
144 stateless_validation->device_extensions = this->device_extensions;
145
146 VkPhysicalDeviceProperties device_properties = {};
147 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600148 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700149 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
150
151 if (device_extensions.vk_nv_shading_rate_image) {
152 // Get the needed shading rate image limits
153 auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
154 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600155 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700156 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
157 }
158
159 if (device_extensions.vk_nv_mesh_shader) {
160 // Get the needed mesh shader limits
161 auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>();
162 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600163 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700164 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
165 }
166
Jason Macnak5c954952019-07-09 15:46:12 -0700167 if (device_extensions.vk_nv_ray_tracing) {
168 // Get the needed ray tracing limits
169 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>();
170 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
171 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
172 phys_dev_ext_props.ray_tracing_props = ray_tracing_props;
173 }
174
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700175 if (device_extensions.vk_ext_transform_feedback) {
176 // Get the needed transform feedback limits
177 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
178 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
179 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
180 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
181 }
182
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800183 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
184
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700185 // Save app-enabled features in this device's validation object
186 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200187 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
188 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
189 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
190 if (features2) {
191 tmp_features2_state.features = features2->features;
192 } else if (pCreateInfo->pEnabledFeatures) {
193 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700194 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200195 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700196 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200197 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700198 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200199 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700200}
201
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700202bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500203 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600204 bool skip = false;
205
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200206 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
207 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
208 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600209 }
210
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200211 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
212 skip |=
213 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
214 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
215 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
216 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600217 }
218
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200219 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700220 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
221 bool negative_viewport =
222 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200223 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700224 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
225 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
226 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200227 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600228 }
229
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600230 {
231 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
232 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
233 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700234 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
235 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
236 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600237 }
238 }
239
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600240 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
241 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600242 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
243 if (features2) {
244 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700245 skip |= LogError(device, kVUID_PVError_InvalidUsage,
246 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
247 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600248 }
249 }
250
Locke77fad1c2019-04-16 13:09:03 -0600251 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
252 if (features2) {
253 if (!instance_extensions.vk_khr_get_physical_device_properties_2) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700254 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
255 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, "
256 "VK_KHR_get_physical_device_properties2 must be enabled when it creates an instance.");
Locke77fad1c2019-04-16 13:09:03 -0600257 }
258 }
259
260 auto vertex_attribute_divisor_features =
261 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
262 if (vertex_attribute_divisor_features) {
263 bool extension_found = false;
264 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
265 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
266 VK_MAX_EXTENSION_NAME_SIZE)) {
267 extension_found = true;
268 break;
269 }
270 }
271 if (!extension_found) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700272 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
273 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
274 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600275 }
276 }
277
Tony-LunarG28017bc2020-01-23 14:40:25 -0700278 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
279 if (vulkan_11_features) {
280 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
281 while (current) {
282 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
283 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
284 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
285 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
286 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
287 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700288 skip |= LogError(
289 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700290 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
291 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
292 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
293 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
294 break;
295 }
296 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
297 }
298 }
299
300 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
301 if (vulkan_12_features) {
302 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
303 while (current) {
304 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
305 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
306 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
307 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
308 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
309 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
310 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
311 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
312 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
313 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
314 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
315 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
316 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700317 skip |= LogError(
318 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700319 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
320 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
321 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
322 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
323 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
324 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
325 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
326 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
327 break;
328 }
329 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
330 }
331 }
332
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600333 // Validate pCreateInfo->pQueueCreateInfos
334 if (pCreateInfo->pQueueCreateInfos) {
335 std::unordered_set<uint32_t> set;
336
337 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
338 const uint32_t requested_queue_family = pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex;
339 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700340 skip |=
341 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
342 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
343 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
344 "index value.",
345 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600346 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700347 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
348 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
349 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
350 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600351 } else {
352 set.insert(requested_queue_family);
353 }
354
355 if (pCreateInfo->pQueueCreateInfos[i].pQueuePriorities != nullptr) {
356 for (uint32_t j = 0; j < pCreateInfo->pQueueCreateInfos[i].queueCount; ++j) {
357 const float queue_priority = pCreateInfo->pQueueCreateInfos[i].pQueuePriorities[j];
358 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700359 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
360 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
361 "] (=%f) is not between 0 and 1 (inclusive).",
362 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600363 }
364 }
365 }
366 }
367 }
368
369 return skip;
370}
371
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500372bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700373 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700374 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
375 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
376 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600377 }
378
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700379 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600380}
381
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700382bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500383 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100384 bool skip = false;
385
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600386 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700387 skip |=
388 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600389
390 // 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 Lobodzinski5d8244a2020-01-23 13:00:43 -0700394 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
395 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
396 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600397 }
398
399 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
400 // queueFamilyIndexCount uint32_t values
401 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700402 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
403 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
404 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
405 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600406 }
407 }
408
409 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
410 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
411 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
412 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700413 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
414 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
415 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600416 }
417 }
418
419 return skip;
420}
421
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700422bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500423 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600424 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600425
426 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600427 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
428 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
429 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
430 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700431 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
432 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
433 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600434 }
435
436 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
437 // queueFamilyIndexCount uint32_t values
438 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700439 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
440 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
441 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
442 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600443 }
444 }
445
Dave Houlton413a6782018-05-22 13:01:54 -0600446 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700447 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600448 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700449 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600450 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700451 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600452
Dave Houlton413a6782018-05-22 13:01:54 -0600453 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700454 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600455 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700456 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600457
Dave Houlton130c0212018-01-29 13:39:56 -0700458 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700459 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
460 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700461 skip |= LogError(
462 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600463 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
464 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700465 }
466
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600467 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100468 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
469 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700470 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
471 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
472 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600473 }
474
475 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100476 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
477 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700478 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
479 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
480 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
481 ") are not equal.",
482 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100483 }
484
485 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700486 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
487 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
488 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
489 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100490 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600491 }
492
493 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700494 skip |= LogError(
495 device, "VUID-VkImageCreateInfo-imageType-00957",
496 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600497 }
498 }
499
Dave Houlton130c0212018-01-29 13:39:56 -0700500 // 3D image may have only 1 layer
501 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700502 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
503 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700504 }
505
506 // If multi-sample, validate type, usage, tiling and mip levels.
507 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
508 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600509 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700510 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
511 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700512 }
513
514 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
515 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
516 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
517 // At least one of the legal attachment bits must be set
518 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700519 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
520 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700521 }
522 // No flags other than the legal attachment bits may be set
523 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
524 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700525 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
526 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700527 }
528 }
529
Jeff Bolzef40fec2018-09-01 22:04:34 -0500530 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600531 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500532 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600533 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
534 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500535 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600536 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700537 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
538 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
539 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600540 }
541
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600542 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700543 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
544 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
545 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600546 }
547
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700548 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700549 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
550 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
551 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100552 }
553
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600554 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
555 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
556 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
557 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700558 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
559 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
560 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600561 }
562
563 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
564 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
565 // Linear tiling is unsupported
566 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700567 skip |= LogError(device, kVUID_PVError_InvalidUsage,
568 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
569 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600570 }
571
572 // Sparse 1D image isn't valid
573 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700574 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
575 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600576 }
577
578 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700579 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700580 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
581 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
582 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600583 }
584
585 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700586 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700587 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
588 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
589 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600590 }
591
592 // Multi-sample 2D image when device doesn't support it
593 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700594 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600595 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700596 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
597 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
598 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700599 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600600 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700601 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
602 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
603 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700604 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600605 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700606 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
607 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
608 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700609 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600610 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700611 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
612 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
613 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600614 }
615 }
616 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500617
Jeff Bolz9af91c52018-09-01 21:53:57 -0500618 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
619 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700620 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
621 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
622 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500623 }
624 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700625 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
626 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
627 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500628 }
629 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700630 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
631 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
632 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500633 }
634 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500635
636 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600637 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700638 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
639 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
640 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500641 }
642
Dave Houlton142c4cb2018-10-17 15:04:41 -0600643 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700644 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
645 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
646 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
647 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500648 }
649
Dave Houlton142c4cb2018-10-17 15:04:41 -0600650 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700651 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
652 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
653 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
654 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500655 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600656 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700657 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
658 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
659 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
660 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500661 }
662 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500663
664 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
665 if (image_stencil_struct != nullptr) {
666 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
667 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
668 // No flags other than the legal attachment bits may be set
669 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
670 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700671 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
672 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
673 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
674 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500675 }
676 }
677
678 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
679 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
680 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
681 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700682 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
683 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
684 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
685 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500686 }
687
688 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
689 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700690 LogError(device, "VUID-VkImageCreateInfo-format-02537",
691 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
692 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
693 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500694 }
695 }
696
697 if (!physical_device_features.shaderStorageImageMultisample &&
698 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
699 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
700 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700701 LogError(device, "VUID-VkImageCreateInfo-format-02538",
702 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
703 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
704 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500705 }
706
707 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
708 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700709 skip |= LogError(
710 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500711 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
712 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
713 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
714 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
715 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700716 skip |= LogError(
717 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500718 "vkCreateImage(): Depth-stencil image in which usage does not include "
719 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
720 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
721 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
722 }
723
724 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
725 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700726 skip |= LogError(
727 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500728 "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)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700733 skip |= LogError(
734 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500735 "vkCreateImage(): Depth-stencil image in which usage does not include "
736 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
737 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
738 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
739 }
740 }
741 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600742 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500743
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600744 return skip;
745}
746
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600747bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700748 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100749 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100750
751 // Note: for numerical correctness
752 // - float comparisons should expect NaN (comparison always false).
753 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
754
755 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -0700756 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100757 if (v1_f <= 0.0f) return true;
758
759 float intpart;
760 const float fract = modff(v1_f, &intpart);
761
762 assert(std::numeric_limits<float>::radix == 2);
763 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
764 if (intpart >= u32_max_plus1) return false;
765
766 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
767 if (v1_u32 < v2_u32)
768 return true;
769 else if (v1_u32 == v2_u32 && fract == 0.0f)
770 return true;
771 else
772 return false;
773 };
774
775 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
776 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
777 return (v1_f <= v2_f);
778 };
779
780 // width
781 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700782 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100783
784 if (!(viewport.width > 0.0f)) {
785 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700786 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
787 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100788 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
789 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700790 skip |= LogError(object, "VUID-VkViewport-width-01771",
791 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
792 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100793 } else if (!f_lte_u32_exact(viewport.width, max_w) && f_lte_u32_direct(viewport.width, max_w)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700794 skip |= LogWarning(object, kVUID_PVError_NONE,
795 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
796 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
797 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100798 }
799
800 // height
801 bool height_healthy = true;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700802 const bool negative_height_enabled = api_version >= VK_API_VERSION_1_1 || device_extensions.vk_khr_maintenance1 ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700803 device_extensions.vk_amd_negative_viewport_height;
804 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100805
806 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
807 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700808 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
809 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100810 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
811 height_healthy = false;
812
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700813 skip |= LogError(object, "VUID-VkViewport-height-01773",
814 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
815 ").",
816 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100817 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
818 height_healthy = false;
819
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700820 skip |= LogWarning(
821 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +0100822 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600823 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600824 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100825 }
826
827 // x
828 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700829 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100830 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700831 skip |= LogError(object, "VUID-VkViewport-x-01774",
832 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
833 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100834 }
835
836 // x + width
837 if (x_healthy && width_healthy) {
838 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700839 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700840 skip |= LogError(
841 object, "VUID-VkViewport-x-01232",
842 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
843 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
844 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100845 }
846 }
847
848 // y
849 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700850 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100851 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700852 skip |= LogError(object, "VUID-VkViewport-y-01775",
853 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
854 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700855 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100856 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700857 skip |= LogError(object, "VUID-VkViewport-y-01776",
858 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
859 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100860 }
861
862 // y + height
863 if (y_healthy && height_healthy) {
864 const float boundary = viewport.y + viewport.height;
865
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700866 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700867 skip |= LogError(object, "VUID-VkViewport-y-01233",
868 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
869 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
870 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700871 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600872 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700873 LogError(object, "VUID-VkViewport-y-01777",
874 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
875 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
876 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100877 }
878 }
879
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700880 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100881 // minDepth
882 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700883 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600884
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700885 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
886 "[0.0, 1.0] range.",
887 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100888 }
889
890 // maxDepth
891 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700892 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600893
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700894 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
895 "[0.0, 1.0] range.",
896 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100897 }
898 }
899
900 return skip;
901}
902
Dave Houlton142c4cb2018-10-17 15:04:41 -0600903struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500904 VkShadingRatePaletteEntryNV shadingRate;
905 uint32_t width;
906 uint32_t height;
907};
908
909// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -0600910static SampleOrderInfo sampleOrderInfos[] = {
911 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
912 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
913 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
914 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
915 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
916 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -0500917};
918
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500919bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500920 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -0500921
Jeff Bolz45bf7d62018-09-18 15:39:58 -0500922 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -0500923 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -0500924 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500925 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500926 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -0500927 break;
928 }
929 }
930
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500931 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700932 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
933 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
934 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500935 return skip;
936 }
937
Dave Houlton142c4cb2018-10-17 15:04:41 -0600938 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700939 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700940 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
941 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
942 ") must "
943 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
944 "is set in framebufferNoAttachmentsSampleCounts.",
945 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -0500946 }
947
Jeff Bolz9af91c52018-09-01 21:53:57 -0500948 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700949 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
950 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
951 ") must "
952 "be equal to the product of sampleCount (=%" PRIu32
953 "), the fragment width for shadingRate "
954 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
955 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -0500956 }
957
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700958 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700959 skip |= LogError(
960 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -0600961 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
962 ") must "
963 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700964 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -0500965 }
Jeff Bolz9af91c52018-09-01 21:53:57 -0500966
967 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500968 // the first width*height*sampleCount bits to all be set. Note: There is no
969 // guarantee that 64 bits is enough, but practically it's unlikely for an
970 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700971 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -0500972 uint64_t sampleLocationsMask = 0;
973 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
974 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
975 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700976 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
977 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500978 }
979 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700980 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
981 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500982 }
983 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700984 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
985 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500986 }
987 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
988 sampleLocationsMask |= 1ULL << idx;
989 }
990
991 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
992 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700993 skip |= LogError(
994 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -0600995 "The array pSampleLocations must contain exactly one entry for "
996 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500997 }
998
999 return skip;
1000}
1001
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001002bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1003 uint32_t createInfoCount,
1004 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1005 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001006 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001007 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001008
1009 if (pCreateInfos != nullptr) {
1010 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001011 bool has_dynamic_viewport = false;
1012 bool has_dynamic_scissor = false;
1013 bool has_dynamic_line_width = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001014 bool has_dynamic_viewport_w_scaling_nv = false;
1015 bool has_dynamic_discard_rectangle_ext = false;
1016 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001017 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001018 bool has_dynamic_shading_rate_palette_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001019 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001020 if (pCreateInfos[i].pDynamicState != nullptr) {
1021 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1022 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1023 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
1024 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) has_dynamic_viewport = true;
1025 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) has_dynamic_scissor = true;
1026 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) has_dynamic_line_width = true;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001027 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) has_dynamic_viewport_w_scaling_nv = true;
1028 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) has_dynamic_discard_rectangle_ext = true;
1029 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) has_dynamic_sample_locations_ext = true;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001030 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) has_dynamic_exclusive_scissor_nv = true;
Dave Houlton142c4cb2018-10-17 15:04:41 -06001031 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV)
1032 has_dynamic_shading_rate_palette_nv = true;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001033 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) has_dynamic_line_stipple = true;
Petr Kraus299ba622017-11-24 03:09:03 +01001034 }
1035 }
1036
Peter Chen85366392019-05-14 15:20:11 -04001037 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1038 if ((feedback_struct != nullptr) &&
1039 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001040 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1041 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1042 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1043 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1044 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001045 }
1046
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001047 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001048
1049 // Collect active stages
1050 uint32_t active_shaders = 0;
1051 for (uint32_t stages = 0; stages < pCreateInfos[i].stageCount; stages++) {
Spencer Fricked84808f2020-01-20 06:08:01 -08001052 active_shaders |= pCreateInfos[i].pStages[stages].stage;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001053 }
1054
1055 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1056 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1057 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1058 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1059 pCreateInfos[i].pTessellationState,
1060 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1061 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1062
1063 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1064 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1065
1066 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1067 "VkPipelineTessellationDomainOriginStateCreateInfo",
1068 pCreateInfos[i].pTessellationState->pNext,
1069 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1070 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
1071 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext");
1072
1073 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1074 pCreateInfos[i].pTessellationState->flags,
1075 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1076 }
1077
1078 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1079 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1080 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1081 pCreateInfos[i].pInputAssemblyState,
1082 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1083 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1084
1085 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1086 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
1087 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext");
1088
1089 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1090 pCreateInfos[i].pInputAssemblyState->flags,
1091 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1092
1093 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1094 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1095 pCreateInfos[i].pInputAssemblyState->topology,
1096 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1097
1098 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1099 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1100 }
1101
1102 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001103 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001104
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001105 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001106 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1107 "vkCreateGraphicsPipelines: pararameter "
1108 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1109 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001110 }
1111
1112 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1113 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1114 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1115 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1116 pCreateInfos[i].pVertexInputState->pNext, 1,
1117 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
1118 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext");
1119 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1120 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001121 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001122 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1123 skip |=
1124 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1125 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1126 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1127 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1128 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1129
1130 skip |= validate_array(
1131 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1132 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1133 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1134 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1135
1136 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1137 for (uint32_t vertexBindingDescriptionIndex = 0;
1138 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1139 ++vertexBindingDescriptionIndex) {
1140 skip |= validate_ranged_enum(
1141 "vkCreateGraphicsPipelines",
1142 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1143 AllVkVertexInputRateEnums,
1144 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1145 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1146 }
1147 }
1148
1149 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1150 for (uint32_t vertexAttributeDescriptionIndex = 0;
1151 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1152 ++vertexAttributeDescriptionIndex) {
1153 skip |= validate_ranged_enum(
1154 "vkCreateGraphicsPipelines",
1155 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1156 AllVkFormatEnums,
1157 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1158 "VUID-VkVertexInputAttributeDescription-format-parameter");
1159 }
1160 }
1161
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001162 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001163 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1164 "vkCreateGraphicsPipelines: pararameter "
1165 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1166 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1167 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001168 }
1169
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001170 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001171 skip |=
1172 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1173 "vkCreateGraphicsPipelines: pararameter "
1174 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1175 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1176 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001177 }
1178
1179 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001180 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1181 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001182 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1183 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001184 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1185 "vkCreateGraphicsPipelines: parameter "
1186 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1187 "(%" PRIu32 ") is not distinct.",
1188 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001189 }
1190 vertex_bindings.insert(vertex_bind_desc.binding);
1191
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001192 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001193 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1194 "vkCreateGraphicsPipelines: parameter "
1195 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1196 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1197 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001198 }
1199
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001200 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001201 skip |=
1202 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1203 "vkCreateGraphicsPipelines: parameter "
1204 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1205 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1206 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001207 }
1208 }
1209
Peter Kohautc7d9d392018-07-15 00:34:07 +02001210 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001211 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1212 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001213 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1214 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001215 skip |= LogError(
1216 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001217 "vkCreateGraphicsPipelines: parameter "
1218 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1219 i, d, vertex_attrib_desc.location);
1220 }
1221 attribute_locations.insert(vertex_attrib_desc.location);
1222
1223 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1224 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001225 skip |= LogError(
1226 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001227 "vkCreateGraphicsPipelines: parameter "
1228 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1229 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1230 i, d, vertex_attrib_desc.binding, i);
1231 }
1232
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001233 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001234 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1235 "vkCreateGraphicsPipelines: parameter "
1236 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1237 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1238 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001239 }
1240
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001241 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001242 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1243 "vkCreateGraphicsPipelines: parameter "
1244 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1245 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1246 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001247 }
1248
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001249 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001250 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1251 "vkCreateGraphicsPipelines: parameter "
1252 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1253 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1254 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001255 }
1256 }
1257 }
1258
1259 if (pCreateInfos[i].pStages != nullptr) {
1260 bool has_control = false;
1261 bool has_eval = false;
1262
1263 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1264 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1265 has_control = true;
1266 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1267 has_eval = true;
1268 }
1269 }
1270
1271 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1272 if (has_control && has_eval) {
1273 if (pCreateInfos[i].pTessellationState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001274 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1275 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1276 "shader stage and a tessellation evaluation shader stage, "
1277 "pCreateInfos[%d].pTessellationState must not be NULL.",
1278 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001279 } else {
Lockee04009e2019-03-08 12:22:35 -07001280 const VkStructureType allowed_type =
1281 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001282 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001283 "vkCreateGraphicsPipelines",
Lockee04009e2019-03-08 12:22:35 -07001284 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1285 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1286 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001287
1288 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001289 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001290 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001291 pCreateInfos[i].pTessellationState->flags,
1292 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001293
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001294 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001295 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001296 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1297 "vkCreateGraphicsPipelines: invalid parameter "
1298 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1299 "should be >0 and <=%u.",
1300 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1301 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001302 }
1303 }
1304 }
1305 }
1306
1307 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1308 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1309 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1310 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001311 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1312 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1313 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1314 "].pViewportState (=NULL) is not a valid pointer.",
1315 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001316 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001317 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1318
1319 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001320 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1321 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1322 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1323 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001324 }
1325
Petr Krausa6103552017-11-16 21:21:58 +01001326 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1327 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001328 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1329 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001330 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1331 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001332 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001333 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001334 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001335 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001336 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001337 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1338 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001339 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
Dave Houlton413a6782018-05-22 13:01:54 -06001340 allowed_structs_VkPipelineViewportStateCreateInfo, 65,
1341 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001342
1343 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001344 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001345 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001346 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001347
Dave Houlton142c4cb2018-10-17 15:04:41 -06001348 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1349 pCreateInfos[i].pViewportState->pNext);
1350 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1351 pCreateInfos[i].pViewportState->pNext);
1352 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1353 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001354 const auto vp_swizzle_struct =
1355 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001356 const auto vp_w_scaling_struct =
1357 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001358
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001359 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001360 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001361 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1362 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1363 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1364 ") is not 1.",
1365 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001366 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001367
Petr Krausa6103552017-11-16 21:21:58 +01001368 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001369 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1370 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1371 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1372 ") is not 1.",
1373 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001374 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001375
Dave Houlton142c4cb2018-10-17 15:04:41 -06001376 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1377 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001378 skip |= LogError(
1379 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1380 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1381 "disabled, but pCreateInfos[%" PRIu32
1382 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1383 ") is not 1.",
1384 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001385 }
1386
Jeff Bolz9af91c52018-09-01 21:53:57 -05001387 if (shading_rate_image_struct &&
1388 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001389 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
1390 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1391 "disabled, but pCreateInfos[%" PRIu32
1392 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
1393 ") is neither 0 nor 1.",
1394 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001395 }
1396
Petr Krausa6103552017-11-16 21:21:58 +01001397 } else { // multiViewport enabled
1398 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001399 skip |= LogError(
1400 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001401 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001402 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001403 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
1404 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1405 "].pViewportState->viewportCount (=%" PRIu32
1406 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1407 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001408 }
Petr Krausa6103552017-11-16 21:21:58 +01001409
1410 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001411 skip |= LogError(
1412 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001413 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001414 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001415 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
1416 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1417 "].pViewportState->scissorCount (=%" PRIu32
1418 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1419 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001420 }
1421 }
1422
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001423 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001424 skip |=
1425 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1426 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1427 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1428 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001429 }
1430
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001431 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001432 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1433 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1434 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1435 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1436 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001437 }
1438
Petr Krausa6103552017-11-16 21:21:58 +01001439 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001440 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
1441 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1442 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1443 "].pViewportState->viewportCount (=%" PRIu32 ").",
1444 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001445 }
1446
Dave Houlton142c4cb2018-10-17 15:04:41 -06001447 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001448 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001449 skip |=
1450 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1451 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1452 ") must be zero or identical to pCreateInfos[%" PRIu32
1453 "].pViewportState->viewportCount (=%" PRIu32 ").",
1454 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001455 }
1456
Dave Houlton142c4cb2018-10-17 15:04:41 -06001457 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001458 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001459 skip |= LogError(
1460 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001461 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1462 "] "
1463 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1464 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1465 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001466 }
1467
Petr Krausa6103552017-11-16 21:21:58 +01001468 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001469 skip |= LogError(
1470 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001471 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1472 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001473 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1474 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001475 }
1476
1477 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001478 skip |= LogError(
1479 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001480 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1481 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001482 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1483 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001484 }
1485
Jeff Bolz3e71f782018-08-29 23:15:45 -05001486 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001487 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1488 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1489 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001490 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-pDynamicStates-02030",
1491 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1492 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1493 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1494 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001495 }
1496
Jeff Bolz9af91c52018-09-01 21:53:57 -05001497 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001498 shading_rate_image_struct->viewportCount > 0 &&
1499 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001500 skip |= LogError(
1501 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-pDynamicStates-02057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001502 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001503 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1504 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001505 i, i);
1506 }
1507
Chris Mayer328d8212018-12-11 14:16:18 +01001508 if (vp_swizzle_struct) {
1509 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001510 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
1511 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
1512 " does "
1513 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
1514 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01001515 }
1516 }
1517
Petr Krausb3fcdb42018-01-09 22:09:09 +01001518 // validate the VkViewports
1519 if (!has_dynamic_viewport && viewport_state.pViewports) {
1520 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
1521 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001522 const char *fn_name = "vkCreateGraphicsPipelines";
1523 skip |= manual_PreCallValidateViewport(viewport, fn_name,
1524 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
1525 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001526 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01001527 }
1528 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001529
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001530 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001531 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1532 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1533 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
1534 "VK_NV_clip_space_w_scaling extension is not enabled.",
1535 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001536 }
1537
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001538 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001539 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1540 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1541 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
1542 "VK_EXT_discard_rectangles extension is not enabled.",
1543 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001544 }
1545
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001546 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001547 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1548 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1549 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
1550 "VK_EXT_sample_locations extension is not enabled.",
1551 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001552 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001553
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001554 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001555 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1556 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1557 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
1558 "VK_NV_scissor_exclusive extension is not enabled.",
1559 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001560 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001561
1562 if (coarse_sample_order_struct &&
1563 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
1564 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001565 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
1566 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1567 "] "
1568 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
1569 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
1570 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001571 }
1572
1573 if (coarse_sample_order_struct) {
1574 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001575 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001576 }
1577 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001578
1579 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
1580 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001581 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
1582 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1583 "] "
1584 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
1585 ") "
1586 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
1587 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001588 }
1589 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001590 skip |= LogError(
1591 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001592 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1593 "] "
1594 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
1595 i);
1596 }
1597 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001598 }
1599
1600 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001601 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
1602 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
1603 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
1604 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001605 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07001606 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
1607 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
1608 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07001609 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07001610 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07001611 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001612 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001613 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07001614 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001615 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
1616 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001617
1618 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001619 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001620 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001621 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001622
1623 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001624 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001625 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
1626 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
1627
1628 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001629 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001630 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1631 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00001632 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06001633 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001634
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001635 skip |= validate_flags(
1636 "vkCreateGraphicsPipelines",
1637 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1638 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02001639 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001640
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001641 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001642 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001643 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
1644 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
1645
1646 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001647 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001648 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
1649 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
1650
1651 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001652 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
1653 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
1654 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
1655 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001656 }
John Zulauf7acac592017-11-06 11:15:53 -07001657 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001658 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001659 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
1660 "vkCreateGraphicsPipelines(): parameter "
1661 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
1662 i);
John Zulauf7acac592017-11-06 11:15:53 -07001663 }
1664 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
1665 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
1666 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001667 skip |= LogError(
1668 device,
1669
Dave Houlton413a6782018-05-22 13:01:54 -06001670 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001671 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07001672 }
1673 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001674
1675 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
1676 pCreateInfos[i].pRasterizationState->pNext);
1677
1678 if (line_state) {
1679 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
1680 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
1681 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
1682 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001683 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1684 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1685 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
1686 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001687 }
1688 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
1689 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001690 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1691 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1692 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
1693 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001694 }
1695 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
1696 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001697 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1698 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1699 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
1700 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001701 }
1702 }
1703 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
1704 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
1705 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001706 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
1707 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
1708 "range [1,256].",
1709 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001710 }
1711 }
1712 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07001713 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001714 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1715 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001716 skip |=
1717 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
1718 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1719 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
1720 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001721 }
1722 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1723 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001724 skip |=
1725 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
1726 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1727 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
1728 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001729 }
1730 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1731 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001732 skip |=
1733 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
1734 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1735 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
1736 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001737 }
1738 if (line_state->stippledLineEnable) {
1739 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1740 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001741 skip |=
1742 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
1743 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1744 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
1745 "stippledRectangularLines feature.",
1746 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001747 }
1748 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1749 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001750 skip |=
1751 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
1752 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1753 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
1754 "stippledBresenhamLines feature.",
1755 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001756 }
1757 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1758 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001759 skip |=
1760 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
1761 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1762 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
1763 "stippledSmoothLines feature.",
1764 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001765 }
1766 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
1767 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001768 skip |=
1769 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
1770 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1771 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
1772 "stippledRectangularLines and strictLines features.",
1773 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001774 }
1775 }
1776 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001777 }
1778
Petr Krause91f7a12017-12-14 20:57:36 +01001779 bool uses_color_attachment = false;
1780 bool uses_depthstencil_attachment = false;
1781 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07001782 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001783 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
1784 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01001785 const auto &subpasses_uses = subpasses_uses_it->second;
1786 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
1787 uses_color_attachment = true;
1788 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
1789 uses_depthstencil_attachment = true;
1790 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07001791 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01001792 }
1793
1794 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001795 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001796 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001797 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001798 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
Dave Houlton413a6782018-05-22 13:01:54 -06001799 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001800
1801 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001802 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001803 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001804 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001805
1806 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001807 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001808 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
1809 pCreateInfos[i].pDepthStencilState->depthTestEnable);
1810
1811 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001812 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001813 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
1814 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
1815
1816 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001817 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001818 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
1819 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001820 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001821
1822 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001823 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001824 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
1825 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
1826
1827 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001828 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001829 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
1830 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
1831
1832 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001833 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001834 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
1835 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001836 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001837
1838 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001839 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001840 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
1841 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001842 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001843
1844 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001845 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001846 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
1847 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001848 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001849
1850 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001851 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001852 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
1853 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001854 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001855
1856 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001857 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001858 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
1859 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001860 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001861
1862 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001863 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001864 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
1865 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001866 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001867
1868 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001869 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001870 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
1871 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001872 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001873
1874 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001875 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001876 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
1877 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001878 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001879
1880 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001881 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
1882 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
1883 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
1884 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001885 }
1886 }
1887
Shannon McPherson9b9532b2018-10-24 12:00:09 -06001888 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
1889 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
1890
Petr Krause91f7a12017-12-14 20:57:36 +01001891 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001892 skip |= validate_struct_type("vkCreateGraphicsPipelines",
1893 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
1894 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
1895 pCreateInfos[i].pColorBlendState,
1896 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
1897 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
1898
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001899 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001900 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06001901 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
1902 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
1903 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001904 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
Dave Houlton413a6782018-05-22 13:01:54 -06001905 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001906
1907 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001908 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001909 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001910 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001911
1912 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001913 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001914 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
1915 pCreateInfos[i].pColorBlendState->logicOpEnable);
1916
1917 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001918 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001919 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
1920 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00001921 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06001922 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001923
1924 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
1925 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
1926 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001927 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001928 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
1929 ParameterName::IndexVector{i, attachmentIndex}),
1930 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
1931
1932 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001933 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001934 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
1935 ParameterName::IndexVector{i, attachmentIndex}),
1936 "VkBlendFactor", AllVkBlendFactorEnums,
1937 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06001938 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001939
1940 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001941 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001942 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
1943 ParameterName::IndexVector{i, attachmentIndex}),
1944 "VkBlendFactor", AllVkBlendFactorEnums,
1945 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06001946 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001947
1948 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001949 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001950 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
1951 ParameterName::IndexVector{i, attachmentIndex}),
1952 "VkBlendOp", AllVkBlendOpEnums,
1953 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001954 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001955
1956 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001957 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001958 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
1959 ParameterName::IndexVector{i, attachmentIndex}),
1960 "VkBlendFactor", AllVkBlendFactorEnums,
1961 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06001962 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001963
1964 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001965 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001966 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
1967 ParameterName::IndexVector{i, attachmentIndex}),
1968 "VkBlendFactor", AllVkBlendFactorEnums,
1969 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06001970 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001971
1972 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001973 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001974 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
1975 ParameterName::IndexVector{i, attachmentIndex}),
1976 "VkBlendOp", AllVkBlendOpEnums,
1977 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001978 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001979
1980 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001981 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001982 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
1983 ParameterName::IndexVector{i, attachmentIndex}),
1984 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
1985 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02001986 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001987 }
1988 }
1989
1990 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001991 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
1992 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
1993 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
1994 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001995 }
1996
1997 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
1998 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
1999 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002000 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002001 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002002 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2003 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002004 }
2005 }
2006 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002007
Petr Kraus9752aae2017-11-24 03:05:50 +01002008 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2009 if (pCreateInfos[i].basePipelineIndex != -1) {
2010 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002011 skip |=
2012 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
2013 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineHandle, must be "
2014 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
2015 "and pCreateInfos->basePipelineIndex is not -1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002016 }
2017 }
2018
Petr Kraus9752aae2017-11-24 03:05:50 +01002019 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2020 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002021 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
2022 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineIndex, must be -1 if "
2023 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
2024 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002025 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002026 } else {
2027 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002028 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2029 "vkCreateGraphicsPipelines parameter pCreateInfos->basePipelineIndex (%d) must be a valid"
2030 "index into the pCreateInfos array, of size %d.",
2031 pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002032 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002033 }
2034 }
2035
Petr Kraus9752aae2017-11-24 03:05:50 +01002036 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002037 if (!device_extensions.vk_nv_fill_rectangle) {
2038 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2039 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002040 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2041 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2042 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2043 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002044 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2045 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002046 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2047 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2048 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2049 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002050 }
2051 } else {
2052 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2053 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2054 (physical_device_features.fillModeNonSolid == false)) {
2055 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002056 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2057 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2058 "pCreateInfos->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2059 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002060 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002061 }
Petr Kraus299ba622017-11-24 03:09:03 +01002062
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002063 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002064 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002065 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2066 "The line width state is static (pCreateInfos[%" PRIu32
2067 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2068 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2069 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2070 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002071 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002072 }
2073
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002074 for (size_t j = 0; j < pCreateInfos[i].stageCount; j++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002075 skip |= validate_string("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002076 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, j}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002077 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[j].pName);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002078 }
2079 }
2080 }
2081
2082 return skip;
2083}
2084
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002085bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2086 uint32_t createInfoCount,
2087 const VkComputePipelineCreateInfo *pCreateInfos,
2088 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002089 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002090 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002091 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002092 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002093 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002094 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002095 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2096 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002097 skip |=
2098 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2099 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2100 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2101 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002102 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002103
2104 // Make sure compute stage is selected
2105 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002106 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2107 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2108 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002109 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002110 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002111 return skip;
2112}
2113
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002114bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002115 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002116 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002117
2118 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002119 const auto &features = physical_device_features;
2120 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002121
John Zulauf71968502017-10-26 13:51:15 -06002122 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2123 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002124 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2125 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2126 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2127 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002128 }
2129
2130 // Anistropy cannot be enabled in sampler unless enabled as a feature
2131 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002132 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2133 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2134 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002135 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002136 }
John Zulauf71968502017-10-26 13:51:15 -06002137
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002138 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2139 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002140 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2141 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2142 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2143 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002144 }
2145 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002146 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2147 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2148 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2149 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002150 }
2151 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002152 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2153 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2154 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2155 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002156 }
2157 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2158 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2159 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2160 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002161 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2162 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2163 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2164 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2165 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2166 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002167 }
2168 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002169 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2170 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2171 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002172 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002173 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002174 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2175 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2176 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002177 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002178 }
2179
2180 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2181 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002182 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2183 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002184 }
2185
2186 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2187 // valid VkBorderColor value
2188 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2189 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2190 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002191 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2192 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002193 }
2194
2195 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2196 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002197 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002198 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2199 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2200 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002201 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002202 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2203 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2204 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002205 }
John Zulauf275805c2017-10-26 15:34:49 -06002206
2207 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002208 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002209 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2210 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002211 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2212 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2213 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002214 }
2215 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002216
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002217 // Check for valid Lod range
2218 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
2219 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2220 "VUID-VkSamplerCreateInfo-maxLod-01973", "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)",
2221 pCreateInfo->minLod, pCreateInfo->maxLod);
2222 }
2223
2224 // Check mipLodBias to device limit
2225 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
2226 skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
2227 "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2228 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2229 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
2230 }
2231
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002232 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2233 if (sampler_conversion != nullptr) {
2234 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2235 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2236 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2237 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002238 skip |= LogError(
2239 device,
2240
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002241 "VUID-VkSamplerCreateInfo-addressModeU-01646",
2242 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2243 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2244 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2245 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2246 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2247 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2248 }
2249 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002250 }
2251
2252 return skip;
2253}
2254
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002255bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2256 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2257 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002258 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002259 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002260
2261 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2262 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2263 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2264 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
2265 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER or VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, and descriptorCount
2266 // is not 0 and pImmutableSamplers is not NULL, pImmutableSamplers must be a pointer to an array of descriptorCount
2267 // valid VkSampler handles
2268 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2269 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2270 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2271 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2272 ++descriptor_index) {
2273 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002274 skip |= LogError(device, kVUID_PVError_RequiredParameter,
2275 "vkCreateDescriptorSetLayout: required parameter "
2276 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2277 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002278 }
2279 }
2280 }
2281
2282 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2283 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2284 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002285 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2286 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2287 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2288 "values.",
2289 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002290 }
2291 }
2292 }
2293 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002294 return skip;
2295}
2296
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002297bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2298 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002299 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002300 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2301 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2302 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002303 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2304 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002305}
2306
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002307bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2308 const VkWriteDescriptorSet *pDescriptorWrites,
2309 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002310 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002311
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002312 if (pDescriptorWrites != NULL) {
2313 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2314 // descriptorCount must be greater than 0
2315 if (pDescriptorWrites[i].descriptorCount == 0) {
2316 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002317 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2318 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002319 }
2320
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002321 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2322 if (validateDstSet) {
2323 // dstSet must be a valid VkDescriptorSet handle
2324 skip |= validate_required_handle(vkCallingFunction,
2325 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2326 pDescriptorWrites[i].dstSet);
2327 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002328
2329 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2330 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2331 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2332 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2333 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2334 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2335 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2336 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures
2337 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002338 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2339 "%s(): if pDescriptorWrites[%d].descriptorType is "
2340 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2341 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2342 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2343 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002344 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2345 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
2346 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageView and imageLayout
2347 // members of any given element of pImageInfo must be a valid VkImageView and VkImageLayout, respectively
2348 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2349 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002350 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002351 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageView",
2352 ParameterName::IndexVector{i, descriptor_index}),
2353 pDescriptorWrites[i].pImageInfo[descriptor_index].imageView);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002354 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002355 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2356 ParameterName::IndexVector{i, descriptor_index}),
2357 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002358 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002359 }
2360 }
2361 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2362 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2363 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2364 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2365 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2366 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2367 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
2368 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002369 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2370 "%s(): if pDescriptorWrites[%d].descriptorType is "
2371 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2372 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2373 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2374 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002375 } else {
2376 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount; ++descriptorIndex) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002377 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002378 ParameterName("pDescriptorWrites[%i].pBufferInfo[%i].buffer",
2379 ParameterName::IndexVector{i, descriptorIndex}),
2380 pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer);
2381 }
2382 }
2383 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2384 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
2385 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
2386 // pTexelBufferView must be a pointer to an array of descriptorCount valid VkBufferView handles
2387 if (pDescriptorWrites[i].pTexelBufferView == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002388 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00323",
2389 "%s(): if pDescriptorWrites[%d].descriptorType is "
2390 "VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, "
2391 "pDescriptorWrites[%d].pTexelBufferView must not be NULL.",
2392 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002393 } else {
2394 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2395 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002396 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002397 ParameterName("pDescriptorWrites[%i].pTexelBufferView[%i]",
2398 ParameterName::IndexVector{i, descriptor_index}),
2399 pDescriptorWrites[i].pTexelBufferView[descriptor_index]);
2400 }
2401 }
2402 }
2403
2404 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2405 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002406 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002407 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2408 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2409 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002410 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002411 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2412 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2413 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2414 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002415 }
2416 }
2417 }
2418 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2419 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002420 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002421 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2422 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2423 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002424 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002425 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
2426 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2427 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2428 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002429 }
2430 }
2431 }
2432 }
2433 }
2434 }
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002435
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002436 return skip;
2437}
2438
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002439bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
2440 const VkWriteDescriptorSet *pDescriptorWrites,
2441 uint32_t descriptorCopyCount,
2442 const VkCopyDescriptorSet *pDescriptorCopies) const {
2443 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
2444}
2445
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002446bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002447 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002448 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002449 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
2450}
2451
2452bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002453 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002454 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002455 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
2456}
2457
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002458bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
2459 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002460 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002461 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002462
2463 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2464 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2465 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002466 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
2467 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002468 return skip;
2469}
2470
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002471bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002472 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002473 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02002474
2475 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
2476 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002477 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
2478
Petr Krause7bb9e82019-08-11 21:34:43 +02002479 // Implicit VUs
2480 // validate only sType here; pointer has to be validated in core_validation
2481 const bool kNotRequired = false;
2482 const char *kNoVUID = nullptr;
2483 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
2484 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
2485 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002486
Petr Krause7bb9e82019-08-11 21:34:43 +02002487 if (pInfo) {
2488 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
2489 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
2490 skip |= validate_struct_pnext(
2491 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
2492 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
2493 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002494
Petr Krause7bb9e82019-08-11 21:34:43 +02002495 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002496
Petr Krause7bb9e82019-08-11 21:34:43 +02002497 // Explicit VUs
2498 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002499 skip |= LogError(
2500 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02002501 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
2502 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002503 }
Petr Krause7bb9e82019-08-11 21:34:43 +02002504
2505 if (physical_device_features.inheritedQueries) {
2506 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002507 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06002508 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02002509 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02002510 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002511 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02002512 }
2513
2514 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02002515 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002516 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002517 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02002518 } else { // !pipelineStatisticsQuery
2519 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
2520 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002521 }
Petr Kraus139757b2019-08-15 17:19:33 +02002522
2523 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
2524 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002525 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02002526 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
2527 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002528 skip |= LogError(
2529 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02002530 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
2531 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
2532 }
2533 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002534 }
2535
2536 return skip;
2537}
2538
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002539bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002540 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002541 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002542
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002543 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01002544 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002545 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
2546 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
2547 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01002548 }
2549 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002550 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
2551 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
2552 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01002553 }
2554 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01002555 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002556 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002557 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
2558 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2559 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2560 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002561 }
2562 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01002563
2564 if (pViewports) {
2565 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
2566 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002567 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002568 skip |= manual_PreCallValidateViewport(
2569 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01002570 }
2571 }
2572
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002573 return skip;
2574}
2575
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002576bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002577 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002578 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002579
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002580 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002581 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002582 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
2583 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
2584 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002585 }
2586 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002587 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
2588 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
2589 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002590 }
2591 } else { // multiViewport enabled
2592 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002593 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002594 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
2595 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2596 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2597 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002598 }
2599 }
2600
Petr Kraus6260f0a2018-02-27 21:15:55 +01002601 if (pScissors) {
2602 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
2603 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002604
Petr Kraus6260f0a2018-02-27 21:15:55 +01002605 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002606 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2607 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
2608 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002609 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002610
Petr Kraus6260f0a2018-02-27 21:15:55 +01002611 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002612 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2613 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
2614 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002615 }
2616
2617 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2618 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002619 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
2620 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2621 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2622 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002623 }
2624
2625 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2626 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002627 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
2628 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2629 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2630 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002631 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002632 }
2633 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01002634
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002635 return skip;
2636}
2637
Jeff Bolz5c801d12019-10-09 10:38:45 -05002638bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01002639 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01002640
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002641 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002642 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
2643 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002644 }
2645
2646 return skip;
2647}
2648
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002649bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002650 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002651 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002652 if (vertexCount == 0) {
2653 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
2654 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002655 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002656 }
2657
2658 if (instanceCount == 0) {
2659 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
2660 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002661 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002662 }
2663 return skip;
2664}
2665
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002666bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002667 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002668 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002669
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002670 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002671 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2672 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002673 }
2674 return skip;
2675}
2676
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002677bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002678 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002679 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002680 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002681 skip |=
2682 LogError(device, kVUID_PVError_DeviceFeature,
2683 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002684 }
2685 return skip;
2686}
2687
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002688bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
2689 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002690 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002691 bool skip = false;
2692 for (uint32_t rect = 0; rect < rectCount; rect++) {
2693 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002694 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
2695 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002696 }
2697 }
2698 return skip;
2699}
2700
Andrew Fobel3abeb992020-01-20 16:33:22 -05002701bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
2702 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2703 VkImageFormatProperties2 *pImageFormatProperties,
2704 const char *apiName) const {
2705 bool skip = false;
2706
2707 if (pImageFormatInfo != nullptr) {
2708 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
2709 if (image_stencil_struct != nullptr) {
2710 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
2711 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
2712 // No flags other than the legal attachment bits may be set
2713 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
2714 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002715 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
2716 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
2717 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
2718 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
2719 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05002720 }
2721 }
2722 }
2723 }
2724
2725 return skip;
2726}
2727
2728bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
2729 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2730 VkImageFormatProperties2 *pImageFormatProperties) const {
2731 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
2732 "vkGetPhysicalDeviceImageFormatProperties2");
2733}
2734
2735bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
2736 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2737 VkImageFormatProperties2 *pImageFormatProperties) const {
2738 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
2739 "vkGetPhysicalDeviceImageFormatProperties2KHR");
2740}
2741
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002742bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
2743 VkImageLayout srcImageLayout, VkImage dstImage,
2744 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002745 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002746 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002747
Dave Houltonf5217612018-02-02 16:18:52 -07002748 VkImageAspectFlags legal_aspect_flags =
2749 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 -07002750 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002751 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2752 }
2753
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002754 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002755 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002756 skip |= LogError(
2757 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002758 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002759 }
Dave Houltonf5217612018-02-02 16:18:52 -07002760 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002761 skip |= LogError(
2762 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002763 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002764 }
2765 }
2766 return skip;
2767}
2768
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002769bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
2770 VkImageLayout srcImageLayout, VkImage dstImage,
2771 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002772 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002773 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002774
Dave Houltonf5217612018-02-02 16:18:52 -07002775 VkImageAspectFlags legal_aspect_flags =
2776 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 -07002777 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002778 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2779 }
2780
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002781 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002782 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002783 skip |= LogError(
2784 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002785 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
2786 }
Dave Houltonf5217612018-02-02 16:18:52 -07002787 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002788 skip |= LogError(
2789 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002790 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
2791 }
2792 }
2793 return skip;
2794}
2795
sfricke-samsung3999ef62020-02-09 17:05:59 -08002796bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
2797 uint32_t regionCount, const VkBufferCopy *pRegions) const {
2798 bool skip = false;
2799
2800 if (pRegions != nullptr) {
2801 for (uint32_t i = 0; i < regionCount; i++) {
2802 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002803 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
2804 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08002805 }
2806 }
2807 }
2808 return skip;
2809}
2810
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002811bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
2812 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002813 uint32_t regionCount,
2814 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002815 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002816
Dave Houltonf5217612018-02-02 16:18:52 -07002817 VkImageAspectFlags legal_aspect_flags =
2818 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 -07002819 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002820 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2821 }
2822
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002823 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002824 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002825 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
2826 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
2827 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002828 }
2829 }
2830 return skip;
2831}
2832
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002833bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
2834 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002835 uint32_t regionCount,
2836 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002837 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002838
Dave Houltonf5217612018-02-02 16:18:52 -07002839 VkImageAspectFlags legal_aspect_flags =
2840 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 -07002841 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002842 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2843 }
2844
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002845 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002846 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002847 LogError(device, kVUID_PVError_UnrecognizedValue,
2848 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
2849 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002850 }
2851 }
2852 return skip;
2853}
2854
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002855bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002856 VkDeviceSize dstOffset, VkDeviceSize dataSize,
2857 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002858 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002859
2860 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002861 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
2862 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
2863 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002864 }
2865
2866 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002867 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
2868 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
2869 "), must be greater than zero and less than or equal to 65536.",
2870 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002871 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002872 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
2873 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
2874 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002875 }
2876 return skip;
2877}
2878
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002879bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002880 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002881 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002882
2883 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002884 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
2885 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
2886 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002887 }
2888
2889 if (size != VK_WHOLE_SIZE) {
2890 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002891 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002892 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
2893 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002894 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002895 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
2896 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002897 }
2898 }
2899 return skip;
2900}
2901
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002902bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002903 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002904 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002905 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002906
2907 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002908 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2909 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
2910 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
2911 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002912 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
2913 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
2914 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002915 }
2916
2917 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
2918 // queueFamilyIndexCount uint32_t values
2919 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002920 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
2921 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
2922 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
2923 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002924 }
2925 }
2926
Dave Houlton413a6782018-05-22 13:01:54 -06002927 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002928 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002929 }
2930
2931 return skip;
2932}
2933
Jeff Bolz5c801d12019-10-09 10:38:45 -05002934bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002935 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002936
2937 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06002938 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
2939 if (present_regions) {
2940 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07002941 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06002942 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
2943 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002944 skip |= LogError(device, kVUID_PVError_InvalidUsage,
2945 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
2946 "extension swapchainCount is %i. These values must be equal.",
2947 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06002948 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002949 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
2950 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext");
2951 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
2952 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
2953 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06002954 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002955 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002956 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06002957 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002958 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002959 }
2960 }
2961
2962 return skip;
2963}
2964
2965#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002966bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
2967 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
2968 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002969 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002970 bool skip = false;
2971
2972 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002973 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
2974 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002975 }
2976
2977 return skip;
2978}
2979#endif // VK_USE_PLATFORM_WIN32_KHR
2980
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002981bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002982 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002983 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02002984 bool skip = false;
2985
2986 if (pCreateInfo) {
2987 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002988 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
2989 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02002990 }
2991
2992 if (pCreateInfo->pPoolSizes) {
2993 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
2994 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002995 skip |= LogError(
2996 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002997 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02002998 }
Jeff Bolze54ae892018-09-08 12:16:29 -05002999 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3000 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003001 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3002 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3003 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3004 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3005 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003006 }
Petr Krausc8655be2017-09-27 18:56:51 +02003007 }
3008 }
3009 }
3010
3011 return skip;
3012}
3013
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003014bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003015 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003016 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003017
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003018 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003019 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003020 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3021 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3022 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003023 }
3024
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003025 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003026 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003027 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3028 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3029 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003030 }
3031
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003032 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003033 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003034 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3035 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3036 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003037 }
3038
3039 return skip;
3040}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003041
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003042bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003043 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003044 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003045
3046 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003047 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3048 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003049 }
3050 return skip;
3051}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003052
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003053bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3054 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003055 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003056 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003057
3058 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003059 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003060 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003061 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3062 "vkCmdDispatch(): baseGroupX (%" PRIu32
3063 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3064 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003065 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003066 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3067 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3068 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3069 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003070 }
3071
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003072 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003073 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003074 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3075 "vkCmdDispatch(): baseGroupY (%" PRIu32
3076 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3077 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003078 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003079 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3080 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3081 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3082 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003083 }
3084
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003085 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003086 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003087 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3088 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3089 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3090 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003091 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003092 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3093 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3094 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3095 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003096 }
3097
3098 return skip;
3099}
3100
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003101bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3102 VkPipelineBindPoint pipelineBindPoint,
3103 VkPipelineLayout layout, uint32_t set,
3104 uint32_t descriptorWriteCount,
3105 const VkWriteDescriptorSet *pDescriptorWrites) const {
3106 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3107}
3108
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003109bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3110 uint32_t firstExclusiveScissor,
3111 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003112 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003113 bool skip = false;
3114
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003115 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003116 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003117 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003118 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3119 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3120 ") is not 0.",
3121 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003122 }
3123 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003124 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003125 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3126 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3127 ") is not 1.",
3128 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003129 }
3130 } else { // multiViewport enabled
3131 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003132 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003133 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3134 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3135 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3136 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003137 }
3138 }
3139
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003140 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003141 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3142 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3143 ") must be less than maxViewports (=%" PRIu32 ").",
3144 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003145 }
3146
3147 if (pExclusiveScissors) {
3148 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3149 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3150
3151 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003152 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3153 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3154 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003155 }
3156
3157 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003158 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3159 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3160 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003161 }
3162
3163 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3164 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003165 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3166 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3167 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3168 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003169 }
3170
3171 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3172 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003173 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3174 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3175 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3176 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003177 }
3178 }
3179 }
3180
3181 return skip;
3182}
3183
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003184bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3185 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003186 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003187 bool skip = false;
3188 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003189 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3190 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3191 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003192 } else {
3193 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3194 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003195 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3196 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3197 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3198 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003199 }
3200 }
3201
3202 return skip;
3203}
3204
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003205bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3206 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003207 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003208 bool skip = false;
3209
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003210 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003211 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003212 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003213 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3214 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3215 ") is not 0.",
3216 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003217 }
3218 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003219 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003220 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3221 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3222 ") is not 1.",
3223 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003224 }
3225 }
3226
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003227 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003228 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3229 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3230 ") must be less than maxViewports (=%" PRIu32 ").",
3231 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003232 }
3233
3234 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003235 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003236 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3237 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3238 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3239 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003240 }
3241
3242 return skip;
3243}
3244
Jeff Bolz5c801d12019-10-09 10:38:45 -05003245bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3246 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3247 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003248 bool skip = false;
3249
Dave Houlton142c4cb2018-10-17 15:04:41 -06003250 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003251 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3252 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3253 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003254 }
3255
3256 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003257 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003258 }
3259
3260 return skip;
3261}
3262
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003263bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003264 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003265 bool skip = false;
3266
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003267 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003268 skip |= LogError(
3269 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003270 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3271 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003272 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003273 }
3274
3275 return skip;
3276}
3277
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003278bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3279 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003280 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003281 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003282 static const int condition_multiples = 0b0011;
3283 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003284 skip |= LogError(
3285 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003286 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003287 }
Lockee1c22882019-06-10 16:02:54 -06003288 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003289 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3290 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3291 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3292 stride);
Lockee1c22882019-06-10 16:02:54 -06003293 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003294 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003295 skip |= LogError(
3296 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3297 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003298 }
3299
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003300 return skip;
3301}
3302
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003303bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3304 VkDeviceSize offset, VkBuffer countBuffer,
3305 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003306 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003307 bool skip = false;
3308
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003309 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003310 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3311 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3312 "), is not a multiple of 4.",
3313 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003314 }
3315
3316 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003317 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
3318 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3319 "), is not a multiple of 4.",
3320 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003321 }
3322
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003323 return skip;
3324}
3325
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003326bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003327 const VkAllocationCallbacks *pAllocator,
3328 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003329 bool skip = false;
3330
3331 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3332 if (pCreateInfo != nullptr) {
3333 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3334 // VkQueryPipelineStatisticFlagBits values
3335 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3336 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003337 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
3338 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3339 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3340 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003341 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003342 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003343 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003344}
3345
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003346bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3347 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003348 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003349 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3350 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003351}
3352
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003353void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003354 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3355 VkResult result) {
3356 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003357 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003358}
3359
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003360void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003361 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3362 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003363 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003364 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003365 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003366}
3367
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003368void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
3369 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003370 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003371 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003372 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003373}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003374
3375bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003376 const VkAllocationCallbacks *pAllocator,
3377 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003378 bool skip = false;
3379
3380 if (pAllocateInfo) {
3381 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
3382 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003383 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
3384 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003385 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003386
3387 VkMemoryAllocateFlags flags = 0;
3388 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
3389 if (flags_info) {
3390 flags = flags_info->flags;
3391 }
3392
3393 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
3394 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
3395 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003396 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
3397 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
3398 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003399 }
3400
3401#ifdef VK_USE_PLATFORM_WIN32_KHR
3402 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
3403#endif
3404 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
3405 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
3406#ifdef VK_USE_PLATFORM_ANDROID_KHR
3407 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
3408#endif
3409
3410 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003411 skip |= LogError(
3412 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003413 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
3414 }
3415 if (
3416#ifdef VK_USE_PLATFORM_WIN32_KHR
3417 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
3418#endif
3419 (import_memory_fd && import_memory_fd->handleType) ||
3420#ifdef VK_USE_PLATFORM_ANDROID_KHR
3421 (import_memory_ahb && import_memory_ahb->buffer) ||
3422#endif
3423 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003424 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
3425 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003426 }
3427 }
3428
3429 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003430 VkBool32 capture_replay = false;
3431 VkBool32 buffer_device_address = false;
3432 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
3433 if (vulkan_12_features) {
3434 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
3435 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
3436 } else {
3437 const auto *bda_features =
3438 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
3439 if (bda_features) {
3440 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
3441 buffer_device_address = bda_features->bufferDeviceAddress;
3442 }
3443 }
3444 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003445 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
3446 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
3447 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003448 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003449 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003450 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
3451 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003452 }
3453 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003454 }
3455 return skip;
3456}
Ricardo Garciaa4935972019-02-21 17:43:18 +01003457
Jason Macnak192fa0e2019-07-26 15:07:16 -07003458bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003459 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003460 bool skip = false;
3461
3462 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
3463 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
3464 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003465 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003466 } else {
3467 uint32_t vertex_component_size = 0;
3468 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
3469 vertex_component_size = 4;
3470 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
3471 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
3472 vertex_component_size = 2;
3473 }
3474 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003475 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003476 }
3477 }
3478
3479 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
3480 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003481 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003482 } else {
3483 uint32_t index_element_size = 0;
3484 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
3485 index_element_size = 4;
3486 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
3487 index_element_size = 2;
3488 }
3489 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003490 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003491 }
3492 }
3493 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
3494 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003495 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003496 }
3497 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003498 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003499 }
3500 }
3501
3502 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003503 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003504 }
3505
3506 return skip;
3507}
3508
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003509bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
3510 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003511 bool skip = false;
3512
3513 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003514 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003515 }
3516 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003517 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003518 }
3519
3520 return skip;
3521}
3522
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003523bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
3524 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003525 bool skip = false;
3526 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003527 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003528 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003529 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003530 }
3531 return skip;
3532}
3533
3534bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003535 VkAccelerationStructureNV object_handle,
Jason Macnak192fa0e2019-07-26 15:07:16 -07003536 const char *func_name) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003537 bool skip = false;
3538 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003539 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
3540 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
3541 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003542 }
3543 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003544 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
3545 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
3546 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003547 }
3548 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
3549 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003550 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
3551 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
3552 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV bit set.");
Jason Macnak5c954952019-07-09 15:46:12 -07003553 }
3554 if (info.geometryCount > phys_dev_ext_props.ray_tracing_props.maxGeometryCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003555 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
3556 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
3557 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003558 }
3559 if (info.instanceCount > phys_dev_ext_props.ray_tracing_props.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003560 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
3561 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
3562 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003563 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003564 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07003565 uint64_t total_triangle_count = 0;
3566 for (uint32_t i = 0; i < info.geometryCount; i++) {
3567 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07003568
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003569 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003570
Jason Macnak5c954952019-07-09 15:46:12 -07003571 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
3572 continue;
3573 }
3574 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
3575 }
3576 if (total_triangle_count > phys_dev_ext_props.ray_tracing_props.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003577 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
3578 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
3579 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003580 }
3581 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003582 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
3583 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
3584 for (uint32_t i = 1; i < info.geometryCount; i++) {
3585 const VkGeometryNV &geometry = info.pGeometries[i];
3586 if (geometry.geometryType != first_geometry_type) {
3587 // TODO: update fake VUID below with the real one once it is generated.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003588 skip |= LogError(device, "UNASSIGNED-VkAccelerationStructureInfoNV-pGeometries-XXXX",
3589 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
3590 "info.pGeometries[0].geometryType.",
3591 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07003592 }
3593 }
3594 }
Jason Macnak5c954952019-07-09 15:46:12 -07003595 return skip;
3596}
3597
Ricardo Garciaa4935972019-02-21 17:43:18 +01003598bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
3599 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003600 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01003601 bool skip = false;
3602
3603 if (pCreateInfo) {
3604 if ((pCreateInfo->compactedSize != 0) &&
3605 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003606 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
3607 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
3608 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
3609 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01003610 }
Jason Macnak5c954952019-07-09 15:46:12 -07003611
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003612 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
Jason Macnak192fa0e2019-07-26 15:07:16 -07003613 "vkCreateAccelerationStructureNV()");
Ricardo Garciaa4935972019-02-21 17:43:18 +01003614 }
3615
3616 return skip;
3617}
Mike Schuchardt21638df2019-03-16 10:52:02 -07003618
Jeff Bolz5c801d12019-10-09 10:38:45 -05003619bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
3620 const VkAccelerationStructureInfoNV *pInfo,
3621 VkBuffer instanceData, VkDeviceSize instanceOffset,
3622 VkBool32 update, VkAccelerationStructureNV dst,
3623 VkAccelerationStructureNV src, VkBuffer scratch,
3624 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003625 bool skip = false;
3626
3627 if (pInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003628 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()");
Jason Macnak5c954952019-07-09 15:46:12 -07003629 }
3630
3631 return skip;
3632}
3633
3634bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
3635 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003636 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003637 bool skip = false;
3638 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003639 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
3640 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07003641 }
3642 return skip;
3643}
3644
Peter Chen85366392019-05-14 15:20:11 -04003645bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
3646 uint32_t createInfoCount,
3647 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
3648 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003649 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04003650 bool skip = false;
3651
3652 for (uint32_t i = 0; i < createInfoCount; i++) {
3653 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
3654 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003655 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
3656 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
3657 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
3658 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
3659 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04003660 }
3661 }
3662
3663 return skip;
3664}
3665
Mike Schuchardt21638df2019-03-16 10:52:02 -07003666#ifdef VK_USE_PLATFORM_WIN32_KHR
3667bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
3668 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003669 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07003670 bool skip = false;
3671 if (!device_extensions.vk_khr_swapchain)
3672 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
3673 if (!device_extensions.vk_khr_get_surface_capabilities_2)
3674 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
3675 if (!device_extensions.vk_khr_surface)
3676 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
3677 if (!device_extensions.vk_khr_get_physical_device_properties_2)
3678 skip |=
3679 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
3680 if (!device_extensions.vk_ext_full_screen_exclusive)
3681 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
3682 skip |= validate_struct_type(
3683 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
3684 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
3685 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
3686 if (pSurfaceInfo != NULL) {
3687 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
3688 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
3689 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
3690
3691 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
3692 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
3693 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
3694 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
3695 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext");
3696
3697 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
3698 }
3699 return skip;
3700}
3701#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01003702
3703bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
3704 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003705 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01003706 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3707 bool skip = false;
3708 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
3709 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
3710 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
3711 }
3712 return skip;
3713}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003714
3715bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003716 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003717 bool skip = false;
3718
3719 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003720 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
3721 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003722 }
3723
3724 return skip;
3725}
Piers Daniell8fd03f52019-08-21 12:07:53 -06003726
3727bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003728 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06003729 bool skip = false;
3730
3731 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003732 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
3733 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06003734 }
3735
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003736 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Piers Daniell8fd03f52019-08-21 12:07:53 -06003737 if (indexType == VK_INDEX_TYPE_UINT8_EXT && !index_type_uint8_features->indexTypeUint8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003738 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
3739 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06003740 }
3741
3742 return skip;
3743}
Mark Lobodzinski84988402019-09-11 15:27:30 -06003744
3745bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003746 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06003747 bool skip = false;
3748 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003749 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
3750 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06003751 }
3752 return skip;
3753}
3754
3755bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003756 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06003757 bool skip = false;
3758 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003759 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
3760 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06003761 }
3762 return skip;
3763}
Petr Kraus3d720392019-11-13 02:52:39 +01003764
3765bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
3766 VkSemaphore semaphore, VkFence fence,
3767 uint32_t *pImageIndex) const {
3768 bool skip = false;
3769
3770 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003771 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
3772 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01003773 }
3774
3775 return skip;
3776}
3777
3778bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
3779 uint32_t *pImageIndex) const {
3780 bool skip = false;
3781
3782 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003783 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
3784 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01003785 }
3786
3787 return skip;
3788}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07003789
3790bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
3791 uint32_t firstInstance, VkBuffer counterBuffer,
3792 VkDeviceSize counterBufferOffset,
3793 uint32_t counterOffset, uint32_t vertexStride) const {
3794 bool skip = false;
3795
3796 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003797 skip |= LogError(
3798 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07003799 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
3800 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
3801 }
3802
3803 return skip;
3804}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08003805
3806bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
3807 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
3808 const VkAllocationCallbacks *pAllocator,
3809 VkSamplerYcbcrConversion *pYcbcrConversion,
3810 const char *apiName) const {
3811 bool skip = false;
3812
3813 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003814 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08003815 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003816 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
3817 "samplerYcbcrConversion must be enabled to call %s.", apiName);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08003818 }
3819 return skip;
3820}
3821
3822bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
3823 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
3824 const VkAllocationCallbacks *pAllocator,
3825 VkSamplerYcbcrConversion *pYcbcrConversion) const {
3826 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
3827 "vkCreateSamplerYcbcrConversion");
3828}
3829
3830bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
3831 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
3832 VkSamplerYcbcrConversion *pYcbcrConversion) const {
3833 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
3834 "vkCreateSamplerYcbcrConversionKHR");
3835}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08003836
3837bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
3838 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
3839 bool skip = false;
3840 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
3841 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
3842
3843 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003844 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
3845 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
3846 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
3847 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
3848 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08003849 }
3850 return skip;
3851}