blob: 01556b6dfb1edcc424e6c8d2aa0d0e398ca45a1e [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
2217 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2218 if (sampler_conversion != nullptr) {
2219 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2220 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2221 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2222 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002223 skip |= LogError(
2224 device,
2225
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002226 "VUID-VkSamplerCreateInfo-addressModeU-01646",
2227 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2228 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2229 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2230 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2231 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2232 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2233 }
2234 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002235 }
2236
2237 return skip;
2238}
2239
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002240bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2241 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2242 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002243 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002244 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002245
2246 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2247 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2248 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2249 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
2250 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER or VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, and descriptorCount
2251 // is not 0 and pImmutableSamplers is not NULL, pImmutableSamplers must be a pointer to an array of descriptorCount
2252 // valid VkSampler handles
2253 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2254 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2255 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2256 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2257 ++descriptor_index) {
2258 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002259 skip |= LogError(device, kVUID_PVError_RequiredParameter,
2260 "vkCreateDescriptorSetLayout: required parameter "
2261 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2262 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002263 }
2264 }
2265 }
2266
2267 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2268 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2269 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002270 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2271 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2272 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2273 "values.",
2274 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002275 }
2276 }
2277 }
2278 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002279 return skip;
2280}
2281
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002282bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2283 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002284 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002285 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2286 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2287 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002288 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2289 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002290}
2291
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002292bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2293 const VkWriteDescriptorSet *pDescriptorWrites,
2294 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002295 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002296
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002297 if (pDescriptorWrites != NULL) {
2298 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2299 // descriptorCount must be greater than 0
2300 if (pDescriptorWrites[i].descriptorCount == 0) {
2301 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002302 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2303 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002304 }
2305
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002306 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2307 if (validateDstSet) {
2308 // dstSet must be a valid VkDescriptorSet handle
2309 skip |= validate_required_handle(vkCallingFunction,
2310 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2311 pDescriptorWrites[i].dstSet);
2312 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002313
2314 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2315 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2316 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2317 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2318 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2319 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2320 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2321 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures
2322 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002323 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2324 "%s(): if pDescriptorWrites[%d].descriptorType is "
2325 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2326 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2327 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2328 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002329 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2330 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
2331 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageView and imageLayout
2332 // members of any given element of pImageInfo must be a valid VkImageView and VkImageLayout, respectively
2333 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2334 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002335 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002336 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageView",
2337 ParameterName::IndexVector{i, descriptor_index}),
2338 pDescriptorWrites[i].pImageInfo[descriptor_index].imageView);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002339 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002340 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2341 ParameterName::IndexVector{i, descriptor_index}),
2342 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002343 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002344 }
2345 }
2346 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2347 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2348 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2349 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2350 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2351 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2352 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
2353 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002354 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2355 "%s(): if pDescriptorWrites[%d].descriptorType is "
2356 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2357 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2358 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2359 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002360 } else {
2361 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount; ++descriptorIndex) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002362 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002363 ParameterName("pDescriptorWrites[%i].pBufferInfo[%i].buffer",
2364 ParameterName::IndexVector{i, descriptorIndex}),
2365 pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer);
2366 }
2367 }
2368 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2369 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
2370 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
2371 // pTexelBufferView must be a pointer to an array of descriptorCount valid VkBufferView handles
2372 if (pDescriptorWrites[i].pTexelBufferView == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002373 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00323",
2374 "%s(): if pDescriptorWrites[%d].descriptorType is "
2375 "VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, "
2376 "pDescriptorWrites[%d].pTexelBufferView must not be NULL.",
2377 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002378 } else {
2379 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2380 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002381 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002382 ParameterName("pDescriptorWrites[%i].pTexelBufferView[%i]",
2383 ParameterName::IndexVector{i, descriptor_index}),
2384 pDescriptorWrites[i].pTexelBufferView[descriptor_index]);
2385 }
2386 }
2387 }
2388
2389 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2390 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002391 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002392 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2393 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2394 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002395 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002396 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2397 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2398 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2399 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002400 }
2401 }
2402 }
2403 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2404 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002405 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002406 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2407 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2408 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002409 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002410 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
2411 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2412 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2413 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002414 }
2415 }
2416 }
2417 }
2418 }
2419 }
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002420
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002421 return skip;
2422}
2423
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002424bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
2425 const VkWriteDescriptorSet *pDescriptorWrites,
2426 uint32_t descriptorCopyCount,
2427 const VkCopyDescriptorSet *pDescriptorCopies) const {
2428 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
2429}
2430
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002431bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002432 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002433 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002434 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
2435}
2436
2437bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002438 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002439 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002440 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
2441}
2442
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002443bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
2444 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002445 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002446 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002447
2448 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2449 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2450 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002451 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
2452 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002453 return skip;
2454}
2455
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002456bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002457 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002458 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02002459
2460 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
2461 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002462 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
2463
Petr Krause7bb9e82019-08-11 21:34:43 +02002464 // Implicit VUs
2465 // validate only sType here; pointer has to be validated in core_validation
2466 const bool kNotRequired = false;
2467 const char *kNoVUID = nullptr;
2468 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
2469 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
2470 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002471
Petr Krause7bb9e82019-08-11 21:34:43 +02002472 if (pInfo) {
2473 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
2474 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
2475 skip |= validate_struct_pnext(
2476 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
2477 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
2478 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002479
Petr Krause7bb9e82019-08-11 21:34:43 +02002480 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002481
Petr Krause7bb9e82019-08-11 21:34:43 +02002482 // Explicit VUs
2483 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002484 skip |= LogError(
2485 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02002486 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
2487 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002488 }
Petr Krause7bb9e82019-08-11 21:34:43 +02002489
2490 if (physical_device_features.inheritedQueries) {
2491 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002492 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06002493 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02002494 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02002495 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002496 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02002497 }
2498
2499 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02002500 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002501 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002502 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02002503 } else { // !pipelineStatisticsQuery
2504 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
2505 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002506 }
Petr Kraus139757b2019-08-15 17:19:33 +02002507
2508 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
2509 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002510 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02002511 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
2512 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002513 skip |= LogError(
2514 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02002515 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
2516 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
2517 }
2518 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002519 }
2520
2521 return skip;
2522}
2523
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002524bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002525 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002526 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002527
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002528 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01002529 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002530 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
2531 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
2532 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01002533 }
2534 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002535 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
2536 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
2537 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01002538 }
2539 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01002540 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002541 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002542 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
2543 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2544 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2545 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002546 }
2547 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01002548
2549 if (pViewports) {
2550 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
2551 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002552 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002553 skip |= manual_PreCallValidateViewport(
2554 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01002555 }
2556 }
2557
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002558 return skip;
2559}
2560
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002561bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002562 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002563 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002564
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002565 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002566 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002567 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
2568 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
2569 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002570 }
2571 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002572 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
2573 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
2574 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002575 }
2576 } else { // multiViewport enabled
2577 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002578 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002579 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
2580 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2581 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2582 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002583 }
2584 }
2585
Petr Kraus6260f0a2018-02-27 21:15:55 +01002586 if (pScissors) {
2587 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
2588 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002589
Petr Kraus6260f0a2018-02-27 21:15:55 +01002590 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002591 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2592 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
2593 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002594 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002595
Petr Kraus6260f0a2018-02-27 21:15:55 +01002596 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002597 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2598 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
2599 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002600 }
2601
2602 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2603 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002604 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
2605 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2606 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2607 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002608 }
2609
2610 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2611 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002612 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
2613 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2614 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2615 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002616 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002617 }
2618 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01002619
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002620 return skip;
2621}
2622
Jeff Bolz5c801d12019-10-09 10:38:45 -05002623bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01002624 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01002625
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002626 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002627 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
2628 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002629 }
2630
2631 return skip;
2632}
2633
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002634bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002635 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002636 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002637 if (vertexCount == 0) {
2638 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
2639 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002640 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002641 }
2642
2643 if (instanceCount == 0) {
2644 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
2645 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002646 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002647 }
2648 return skip;
2649}
2650
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002651bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002652 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002653 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002654
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002655 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002656 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2657 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002658 }
2659 return skip;
2660}
2661
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002662bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002663 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002664 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002665 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002666 skip |=
2667 LogError(device, kVUID_PVError_DeviceFeature,
2668 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002669 }
2670 return skip;
2671}
2672
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002673bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
2674 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002675 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002676 bool skip = false;
2677 for (uint32_t rect = 0; rect < rectCount; rect++) {
2678 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002679 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
2680 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002681 }
2682 }
2683 return skip;
2684}
2685
Andrew Fobel3abeb992020-01-20 16:33:22 -05002686bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
2687 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2688 VkImageFormatProperties2 *pImageFormatProperties,
2689 const char *apiName) const {
2690 bool skip = false;
2691
2692 if (pImageFormatInfo != nullptr) {
2693 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
2694 if (image_stencil_struct != nullptr) {
2695 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
2696 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
2697 // No flags other than the legal attachment bits may be set
2698 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
2699 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002700 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
2701 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
2702 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
2703 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
2704 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05002705 }
2706 }
2707 }
2708 }
2709
2710 return skip;
2711}
2712
2713bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
2714 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2715 VkImageFormatProperties2 *pImageFormatProperties) const {
2716 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
2717 "vkGetPhysicalDeviceImageFormatProperties2");
2718}
2719
2720bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
2721 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2722 VkImageFormatProperties2 *pImageFormatProperties) const {
2723 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
2724 "vkGetPhysicalDeviceImageFormatProperties2KHR");
2725}
2726
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002727bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
2728 VkImageLayout srcImageLayout, VkImage dstImage,
2729 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002730 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002731 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002732
Dave Houltonf5217612018-02-02 16:18:52 -07002733 VkImageAspectFlags legal_aspect_flags =
2734 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 -07002735 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002736 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2737 }
2738
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002739 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002740 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002741 skip |= LogError(
2742 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002743 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002744 }
Dave Houltonf5217612018-02-02 16:18:52 -07002745 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002746 skip |= LogError(
2747 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002748 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002749 }
2750 }
2751 return skip;
2752}
2753
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002754bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
2755 VkImageLayout srcImageLayout, VkImage dstImage,
2756 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002757 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002758 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002759
Dave Houltonf5217612018-02-02 16:18:52 -07002760 VkImageAspectFlags legal_aspect_flags =
2761 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 -07002762 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002763 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2764 }
2765
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002766 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002767 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002768 skip |= LogError(
2769 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002770 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
2771 }
Dave Houltonf5217612018-02-02 16:18:52 -07002772 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002773 skip |= LogError(
2774 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002775 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
2776 }
2777 }
2778 return skip;
2779}
2780
sfricke-samsung3999ef62020-02-09 17:05:59 -08002781bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
2782 uint32_t regionCount, const VkBufferCopy *pRegions) const {
2783 bool skip = false;
2784
2785 if (pRegions != nullptr) {
2786 for (uint32_t i = 0; i < regionCount; i++) {
2787 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002788 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
2789 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08002790 }
2791 }
2792 }
2793 return skip;
2794}
2795
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002796bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
2797 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002798 uint32_t regionCount,
2799 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002800 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002801
Dave Houltonf5217612018-02-02 16:18:52 -07002802 VkImageAspectFlags legal_aspect_flags =
2803 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 -07002804 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002805 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2806 }
2807
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002808 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002809 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002810 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
2811 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
2812 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002813 }
2814 }
2815 return skip;
2816}
2817
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002818bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
2819 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002820 uint32_t regionCount,
2821 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002822 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002823
Dave Houltonf5217612018-02-02 16:18:52 -07002824 VkImageAspectFlags legal_aspect_flags =
2825 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 -07002826 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002827 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2828 }
2829
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002830 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002831 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002832 LogError(device, kVUID_PVError_UnrecognizedValue,
2833 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
2834 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002835 }
2836 }
2837 return skip;
2838}
2839
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002840bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002841 VkDeviceSize dstOffset, VkDeviceSize dataSize,
2842 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002843 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002844
2845 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002846 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
2847 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
2848 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002849 }
2850
2851 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002852 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
2853 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
2854 "), must be greater than zero and less than or equal to 65536.",
2855 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002856 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002857 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
2858 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
2859 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002860 }
2861 return skip;
2862}
2863
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002864bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002865 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002866 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002867
2868 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002869 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
2870 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
2871 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002872 }
2873
2874 if (size != VK_WHOLE_SIZE) {
2875 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002876 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002877 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
2878 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002879 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002880 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
2881 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002882 }
2883 }
2884 return skip;
2885}
2886
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002887bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002888 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002889 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002890 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002891
2892 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002893 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2894 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
2895 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
2896 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002897 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
2898 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
2899 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002900 }
2901
2902 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
2903 // queueFamilyIndexCount uint32_t values
2904 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002905 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
2906 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
2907 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
2908 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002909 }
2910 }
2911
Dave Houlton413a6782018-05-22 13:01:54 -06002912 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002913 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002914 }
2915
2916 return skip;
2917}
2918
Jeff Bolz5c801d12019-10-09 10:38:45 -05002919bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002920 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002921
2922 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06002923 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
2924 if (present_regions) {
2925 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07002926 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06002927 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
2928 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002929 skip |= LogError(device, kVUID_PVError_InvalidUsage,
2930 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
2931 "extension swapchainCount is %i. These values must be equal.",
2932 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06002933 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002934 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
2935 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext");
2936 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
2937 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
2938 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06002939 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002940 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002941 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06002942 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002943 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002944 }
2945 }
2946
2947 return skip;
2948}
2949
2950#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002951bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
2952 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
2953 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002954 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002955 bool skip = false;
2956
2957 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002958 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
2959 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002960 }
2961
2962 return skip;
2963}
2964#endif // VK_USE_PLATFORM_WIN32_KHR
2965
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002966bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002967 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002968 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02002969 bool skip = false;
2970
2971 if (pCreateInfo) {
2972 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002973 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
2974 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02002975 }
2976
2977 if (pCreateInfo->pPoolSizes) {
2978 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
2979 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002980 skip |= LogError(
2981 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002982 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02002983 }
Jeff Bolze54ae892018-09-08 12:16:29 -05002984 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
2985 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002986 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
2987 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
2988 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
2989 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
2990 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05002991 }
Petr Krausc8655be2017-09-27 18:56:51 +02002992 }
2993 }
2994 }
2995
2996 return skip;
2997}
2998
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002999bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003000 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003001 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003002
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003003 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003004 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003005 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3006 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3007 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003008 }
3009
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003010 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003011 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003012 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3013 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3014 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003015 }
3016
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003017 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003018 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003019 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3020 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3021 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003022 }
3023
3024 return skip;
3025}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003026
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003027bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003028 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003029 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003030
3031 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003032 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3033 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003034 }
3035 return skip;
3036}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003037
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003038bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3039 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003040 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003041 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003042
3043 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003044 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003045 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003046 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3047 "vkCmdDispatch(): baseGroupX (%" PRIu32
3048 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3049 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003050 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003051 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3052 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3053 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3054 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003055 }
3056
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003057 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003058 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003059 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3060 "vkCmdDispatch(): baseGroupY (%" PRIu32
3061 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3062 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003063 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003064 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3065 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3066 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3067 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003068 }
3069
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003070 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003071 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003072 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3073 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3074 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3075 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003076 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003077 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3078 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3079 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3080 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003081 }
3082
3083 return skip;
3084}
3085
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003086bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3087 VkPipelineBindPoint pipelineBindPoint,
3088 VkPipelineLayout layout, uint32_t set,
3089 uint32_t descriptorWriteCount,
3090 const VkWriteDescriptorSet *pDescriptorWrites) const {
3091 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3092}
3093
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003094bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3095 uint32_t firstExclusiveScissor,
3096 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003097 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003098 bool skip = false;
3099
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003100 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003101 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003102 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003103 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3104 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3105 ") is not 0.",
3106 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003107 }
3108 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003109 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003110 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3111 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3112 ") is not 1.",
3113 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003114 }
3115 } else { // multiViewport enabled
3116 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003117 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003118 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3119 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3120 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3121 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003122 }
3123 }
3124
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003125 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003126 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3127 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3128 ") must be less than maxViewports (=%" PRIu32 ").",
3129 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003130 }
3131
3132 if (pExclusiveScissors) {
3133 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3134 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3135
3136 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003137 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3138 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3139 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003140 }
3141
3142 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003143 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3144 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3145 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003146 }
3147
3148 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3149 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003150 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3151 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3152 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3153 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003154 }
3155
3156 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3157 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003158 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3159 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3160 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3161 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003162 }
3163 }
3164 }
3165
3166 return skip;
3167}
3168
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003169bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3170 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003171 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003172 bool skip = false;
3173 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003174 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3175 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3176 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003177 } else {
3178 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3179 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003180 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3181 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3182 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3183 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003184 }
3185 }
3186
3187 return skip;
3188}
3189
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003190bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3191 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003192 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003193 bool skip = false;
3194
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003195 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003196 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003197 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003198 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3199 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3200 ") is not 0.",
3201 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003202 }
3203 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003204 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003205 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3206 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3207 ") is not 1.",
3208 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003209 }
3210 }
3211
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003212 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003213 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3214 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3215 ") must be less than maxViewports (=%" PRIu32 ").",
3216 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003217 }
3218
3219 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003220 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003221 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3222 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3223 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3224 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003225 }
3226
3227 return skip;
3228}
3229
Jeff Bolz5c801d12019-10-09 10:38:45 -05003230bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3231 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3232 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003233 bool skip = false;
3234
Dave Houlton142c4cb2018-10-17 15:04:41 -06003235 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003236 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3237 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3238 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003239 }
3240
3241 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003242 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003243 }
3244
3245 return skip;
3246}
3247
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003248bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003249 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003250 bool skip = false;
3251
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003252 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003253 skip |= LogError(
3254 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003255 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3256 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003257 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003258 }
3259
3260 return skip;
3261}
3262
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003263bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3264 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003265 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003266 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003267 static const int condition_multiples = 0b0011;
3268 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003269 skip |= LogError(
3270 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003271 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003272 }
Lockee1c22882019-06-10 16:02:54 -06003273 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003274 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3275 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3276 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3277 stride);
Lockee1c22882019-06-10 16:02:54 -06003278 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003279 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003280 skip |= LogError(
3281 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3282 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003283 }
3284
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003285 return skip;
3286}
3287
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003288bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3289 VkDeviceSize offset, VkBuffer countBuffer,
3290 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003291 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003292 bool skip = false;
3293
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003294 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003295 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3296 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3297 "), is not a multiple of 4.",
3298 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003299 }
3300
3301 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003302 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
3303 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3304 "), is not a multiple of 4.",
3305 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003306 }
3307
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003308 return skip;
3309}
3310
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003311bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003312 const VkAllocationCallbacks *pAllocator,
3313 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003314 bool skip = false;
3315
3316 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3317 if (pCreateInfo != nullptr) {
3318 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3319 // VkQueryPipelineStatisticFlagBits values
3320 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3321 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003322 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
3323 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3324 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3325 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003326 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003327 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003328 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003329}
3330
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003331bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3332 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003333 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003334 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3335 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003336}
3337
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003338void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003339 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3340 VkResult result) {
3341 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003342 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003343}
3344
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003345void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003346 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3347 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003348 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003349 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003350 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003351}
3352
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003353void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
3354 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003355 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003356 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003357 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003358}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003359
3360bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003361 const VkAllocationCallbacks *pAllocator,
3362 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003363 bool skip = false;
3364
3365 if (pAllocateInfo) {
3366 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
3367 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003368 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
3369 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003370 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003371
3372 VkMemoryAllocateFlags flags = 0;
3373 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
3374 if (flags_info) {
3375 flags = flags_info->flags;
3376 }
3377
3378 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
3379 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
3380 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003381 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
3382 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
3383 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003384 }
3385
3386#ifdef VK_USE_PLATFORM_WIN32_KHR
3387 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
3388#endif
3389 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
3390 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
3391#ifdef VK_USE_PLATFORM_ANDROID_KHR
3392 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
3393#endif
3394
3395 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003396 skip |= LogError(
3397 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003398 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
3399 }
3400 if (
3401#ifdef VK_USE_PLATFORM_WIN32_KHR
3402 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
3403#endif
3404 (import_memory_fd && import_memory_fd->handleType) ||
3405#ifdef VK_USE_PLATFORM_ANDROID_KHR
3406 (import_memory_ahb && import_memory_ahb->buffer) ||
3407#endif
3408 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003409 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
3410 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003411 }
3412 }
3413
3414 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003415 VkBool32 capture_replay = false;
3416 VkBool32 buffer_device_address = false;
3417 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
3418 if (vulkan_12_features) {
3419 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
3420 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
3421 } else {
3422 const auto *bda_features =
3423 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
3424 if (bda_features) {
3425 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
3426 buffer_device_address = bda_features->bufferDeviceAddress;
3427 }
3428 }
3429 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003430 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
3431 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
3432 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003433 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003434 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003435 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
3436 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003437 }
3438 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003439 }
3440 return skip;
3441}
Ricardo Garciaa4935972019-02-21 17:43:18 +01003442
Jason Macnak192fa0e2019-07-26 15:07:16 -07003443bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003444 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003445 bool skip = false;
3446
3447 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
3448 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
3449 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003450 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003451 } else {
3452 uint32_t vertex_component_size = 0;
3453 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
3454 vertex_component_size = 4;
3455 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
3456 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
3457 vertex_component_size = 2;
3458 }
3459 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003460 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003461 }
3462 }
3463
3464 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
3465 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003466 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003467 } else {
3468 uint32_t index_element_size = 0;
3469 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
3470 index_element_size = 4;
3471 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
3472 index_element_size = 2;
3473 }
3474 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003475 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003476 }
3477 }
3478 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
3479 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003480 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003481 }
3482 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003483 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003484 }
3485 }
3486
3487 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003488 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003489 }
3490
3491 return skip;
3492}
3493
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003494bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
3495 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003496 bool skip = false;
3497
3498 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003499 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003500 }
3501 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003502 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003503 }
3504
3505 return skip;
3506}
3507
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003508bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
3509 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003510 bool skip = false;
3511 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003512 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003513 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003514 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003515 }
3516 return skip;
3517}
3518
3519bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003520 VkAccelerationStructureNV object_handle,
Jason Macnak192fa0e2019-07-26 15:07:16 -07003521 const char *func_name) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003522 bool skip = false;
3523 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003524 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
3525 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
3526 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003527 }
3528 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003529 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
3530 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
3531 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003532 }
3533 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
3534 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003535 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
3536 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
3537 "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 -07003538 }
3539 if (info.geometryCount > phys_dev_ext_props.ray_tracing_props.maxGeometryCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003540 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
3541 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
3542 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003543 }
3544 if (info.instanceCount > phys_dev_ext_props.ray_tracing_props.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003545 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
3546 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
3547 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003548 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003549 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07003550 uint64_t total_triangle_count = 0;
3551 for (uint32_t i = 0; i < info.geometryCount; i++) {
3552 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07003553
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003554 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003555
Jason Macnak5c954952019-07-09 15:46:12 -07003556 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
3557 continue;
3558 }
3559 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
3560 }
3561 if (total_triangle_count > phys_dev_ext_props.ray_tracing_props.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003562 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
3563 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
3564 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003565 }
3566 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003567 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
3568 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
3569 for (uint32_t i = 1; i < info.geometryCount; i++) {
3570 const VkGeometryNV &geometry = info.pGeometries[i];
3571 if (geometry.geometryType != first_geometry_type) {
3572 // TODO: update fake VUID below with the real one once it is generated.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003573 skip |= LogError(device, "UNASSIGNED-VkAccelerationStructureInfoNV-pGeometries-XXXX",
3574 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
3575 "info.pGeometries[0].geometryType.",
3576 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07003577 }
3578 }
3579 }
Jason Macnak5c954952019-07-09 15:46:12 -07003580 return skip;
3581}
3582
Ricardo Garciaa4935972019-02-21 17:43:18 +01003583bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
3584 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003585 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01003586 bool skip = false;
3587
3588 if (pCreateInfo) {
3589 if ((pCreateInfo->compactedSize != 0) &&
3590 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003591 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
3592 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
3593 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
3594 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01003595 }
Jason Macnak5c954952019-07-09 15:46:12 -07003596
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003597 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
Jason Macnak192fa0e2019-07-26 15:07:16 -07003598 "vkCreateAccelerationStructureNV()");
Ricardo Garciaa4935972019-02-21 17:43:18 +01003599 }
3600
3601 return skip;
3602}
Mike Schuchardt21638df2019-03-16 10:52:02 -07003603
Jeff Bolz5c801d12019-10-09 10:38:45 -05003604bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
3605 const VkAccelerationStructureInfoNV *pInfo,
3606 VkBuffer instanceData, VkDeviceSize instanceOffset,
3607 VkBool32 update, VkAccelerationStructureNV dst,
3608 VkAccelerationStructureNV src, VkBuffer scratch,
3609 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003610 bool skip = false;
3611
3612 if (pInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003613 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()");
Jason Macnak5c954952019-07-09 15:46:12 -07003614 }
3615
3616 return skip;
3617}
3618
3619bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
3620 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003621 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003622 bool skip = false;
3623 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003624 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
3625 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07003626 }
3627 return skip;
3628}
3629
Peter Chen85366392019-05-14 15:20:11 -04003630bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
3631 uint32_t createInfoCount,
3632 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
3633 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003634 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04003635 bool skip = false;
3636
3637 for (uint32_t i = 0; i < createInfoCount; i++) {
3638 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
3639 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003640 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
3641 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
3642 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
3643 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
3644 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04003645 }
3646 }
3647
3648 return skip;
3649}
3650
Mike Schuchardt21638df2019-03-16 10:52:02 -07003651#ifdef VK_USE_PLATFORM_WIN32_KHR
3652bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
3653 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003654 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07003655 bool skip = false;
3656 if (!device_extensions.vk_khr_swapchain)
3657 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
3658 if (!device_extensions.vk_khr_get_surface_capabilities_2)
3659 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
3660 if (!device_extensions.vk_khr_surface)
3661 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
3662 if (!device_extensions.vk_khr_get_physical_device_properties_2)
3663 skip |=
3664 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
3665 if (!device_extensions.vk_ext_full_screen_exclusive)
3666 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
3667 skip |= validate_struct_type(
3668 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
3669 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
3670 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
3671 if (pSurfaceInfo != NULL) {
3672 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
3673 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
3674 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
3675
3676 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
3677 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
3678 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
3679 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
3680 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext");
3681
3682 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
3683 }
3684 return skip;
3685}
3686#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01003687
3688bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
3689 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003690 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01003691 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3692 bool skip = false;
3693 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
3694 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
3695 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
3696 }
3697 return skip;
3698}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003699
3700bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003701 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003702 bool skip = false;
3703
3704 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003705 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
3706 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003707 }
3708
3709 return skip;
3710}
Piers Daniell8fd03f52019-08-21 12:07:53 -06003711
3712bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003713 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06003714 bool skip = false;
3715
3716 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003717 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
3718 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06003719 }
3720
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003721 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Piers Daniell8fd03f52019-08-21 12:07:53 -06003722 if (indexType == VK_INDEX_TYPE_UINT8_EXT && !index_type_uint8_features->indexTypeUint8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003723 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
3724 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06003725 }
3726
3727 return skip;
3728}
Mark Lobodzinski84988402019-09-11 15:27:30 -06003729
3730bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003731 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06003732 bool skip = false;
3733 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003734 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
3735 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06003736 }
3737 return skip;
3738}
3739
3740bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003741 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06003742 bool skip = false;
3743 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003744 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
3745 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06003746 }
3747 return skip;
3748}
Petr Kraus3d720392019-11-13 02:52:39 +01003749
3750bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
3751 VkSemaphore semaphore, VkFence fence,
3752 uint32_t *pImageIndex) const {
3753 bool skip = false;
3754
3755 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003756 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
3757 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01003758 }
3759
3760 return skip;
3761}
3762
3763bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
3764 uint32_t *pImageIndex) const {
3765 bool skip = false;
3766
3767 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003768 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
3769 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01003770 }
3771
3772 return skip;
3773}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07003774
3775bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
3776 uint32_t firstInstance, VkBuffer counterBuffer,
3777 VkDeviceSize counterBufferOffset,
3778 uint32_t counterOffset, uint32_t vertexStride) const {
3779 bool skip = false;
3780
3781 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003782 skip |= LogError(
3783 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07003784 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
3785 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
3786 }
3787
3788 return skip;
3789}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08003790
3791bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
3792 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
3793 const VkAllocationCallbacks *pAllocator,
3794 VkSamplerYcbcrConversion *pYcbcrConversion,
3795 const char *apiName) const {
3796 bool skip = false;
3797
3798 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003799 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08003800 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003801 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
3802 "samplerYcbcrConversion must be enabled to call %s.", apiName);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08003803 }
3804 return skip;
3805}
3806
3807bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
3808 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
3809 const VkAllocationCallbacks *pAllocator,
3810 VkSamplerYcbcrConversion *pYcbcrConversion) const {
3811 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
3812 "vkCreateSamplerYcbcrConversion");
3813}
3814
3815bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
3816 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
3817 VkSamplerYcbcrConversion *pYcbcrConversion) const {
3818 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
3819 "vkCreateSamplerYcbcrConversionKHR");
3820}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08003821
3822bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
3823 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
3824 bool skip = false;
3825 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
3826 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
3827
3828 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003829 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
3830 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
3831 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
3832 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
3833 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08003834 }
3835 return skip;
3836}