blob: f473c8ec8fa72e701ea503a39a16785e10ba050e [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) {
sfricke-samsung6aec21b2020-11-01 07:49:43 -080058 if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) {
59 skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070060 "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
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060088bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const {
89 if (instance_extensions.vk_khr_get_physical_device_properties_2) {
90 // Struct is legal IF it's supported
91 const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device);
92 if (dev_exts_enumerated == device_extensions_enumerated.end()) return true;
93 auto enum_iter = dev_exts_enumerated->second.find(ext_name);
94 if (enum_iter != dev_exts_enumerated->second.cend()) {
95 return true;
96 }
97 }
98 return false;
99}
100
Tony-LunarG866843d2020-05-13 11:22:42 -0600101bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
102 const VkValidationFeaturesEXT *validation_features) const {
103 bool skip = false;
104 bool debug_printf = false;
105 bool gpu_assisted = false;
106 bool reserve_slot = false;
107 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
108 switch (validation_features->pEnabledValidationFeatures[i]) {
109 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
110 gpu_assisted = true;
111 break;
112
113 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
114 debug_printf = true;
115 break;
116
117 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
118 reserve_slot = true;
119 break;
120
121 default:
122 break;
123 }
124 }
125 if (reserve_slot && !gpu_assisted) {
126 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
127 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
128 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
129 }
130 if (gpu_assisted && debug_printf) {
131 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
132 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
133 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
134 }
135
136 return skip;
137}
138
John Zulauf620755c2018-04-16 11:00:43 -0600139template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700140ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
141 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600142 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700143 ExtEnabled state =
144 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600145 return state;
146}
147
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700148bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500149 const VkAllocationCallbacks *pAllocator,
150 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700151 bool skip = false;
152 // Note: From the spec--
153 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
154 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
155 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700156 ? pCreateInfo->pApplicationInfo->apiVersion
157 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700158 skip |= validate_api_version(local_api_version, api_version);
159 skip |= validate_instance_extensions(pCreateInfo);
Tony-LunarG866843d2020-05-13 11:22:42 -0600160 const auto *validation_features = lvl_find_in_chain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
161 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
162
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700163 return skip;
164}
165
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700166void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700167 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
168 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700169 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
170 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700171 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700172 this->instance_extensions = instance_data->instance_extensions;
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600173
174 uint32_t pdev_count = 0;
175 DispatchEnumeratePhysicalDevices(*pInstance, &pdev_count, nullptr);
176 std::vector<VkPhysicalDevice> physical_devices;
177 physical_devices.resize(pdev_count);
178 DispatchEnumeratePhysicalDevices(*pInstance, &pdev_count, physical_devices.data());
179
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600180 for (uint32_t i = 0; i < physical_devices.size(); i++) {
181 auto phys_dev_props = new VkPhysicalDeviceProperties;
182 DispatchGetPhysicalDeviceProperties(physical_devices[i], phys_dev_props);
183 physical_device_properties_map[physical_devices[i]] = phys_dev_props;
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600184
185 // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state
186 uint32_t ext_count = 0;
187 std::unordered_set<std::string> dev_exts_enumerated{};
188 std::vector<VkExtensionProperties> ext_props{};
189 instance_dispatch_table.EnumerateDeviceExtensionProperties(physical_devices[i], nullptr, &ext_count, nullptr);
190 ext_props.resize(ext_count);
191 instance_dispatch_table.EnumerateDeviceExtensionProperties(physical_devices[i], nullptr, &ext_count, ext_props.data());
192 for (uint32_t j = 0; j < ext_count; j++) {
193 dev_exts_enumerated.insert(ext_props[j].extensionName);
194 }
195 device_extensions_enumerated[physical_devices[i]] = std::move(dev_exts_enumerated);
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600196 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700197}
198
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600199void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
200 for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) {
201 delete (it->second);
202 it = physical_device_properties_map.erase(it);
203 }
204};
205
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700206void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700207 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700208 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700209 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700210 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
211 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700212
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700213 // Parmeter validation also uses extension data
214 stateless_validation->device_extensions = this->device_extensions;
215
216 VkPhysicalDeviceProperties device_properties = {};
217 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600218 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700219 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
220
221 if (device_extensions.vk_nv_shading_rate_image) {
222 // Get the needed shading rate image limits
223 auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
224 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600225 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700226 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
227 }
228
229 if (device_extensions.vk_nv_mesh_shader) {
230 // Get the needed mesh shader limits
231 auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>();
232 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600233 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700234 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
235 }
236
Jason Macnak5c954952019-07-09 15:46:12 -0700237 if (device_extensions.vk_nv_ray_tracing) {
238 // Get the needed ray tracing limits
239 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>();
240 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
241 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500242 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
243 }
244
245 if (device_extensions.vk_khr_ray_tracing) {
246 // Get the needed ray tracing limits
247 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesKHR>();
248 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
249 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
250 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700251 }
252
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700253 if (device_extensions.vk_ext_transform_feedback) {
254 // Get the needed transform feedback limits
255 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
256 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
257 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
258 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
259 }
260
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800261 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
262
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700263 // Save app-enabled features in this device's validation object
264 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200265 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
266 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
267 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
268 if (features2) {
269 tmp_features2_state.features = features2->features;
270 } else if (pCreateInfo->pEnabledFeatures) {
271 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700272 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200273 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700274 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200275 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700276 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200277 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700278}
279
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700280bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500281 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600282 bool skip = false;
283
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200284 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
285 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
286 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600287 }
288
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200289 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
290 skip |=
291 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
292 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
293 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
294 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600295 }
296
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200297 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700298 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
299 bool negative_viewport =
300 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200301 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700302 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
303 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
304 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200305 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600306 }
307
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600308 {
309 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
310 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
311 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700312 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
313 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
314 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600315 }
316 }
317
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600318 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
319 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600320 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
321 if (features2) {
322 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700323 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700324 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
325 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600326 }
327 }
328
Locke77fad1c2019-04-16 13:09:03 -0600329 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500330 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
331 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
332 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
333 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
334 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
335 }
sourav parmara24fb7b2020-05-26 10:50:04 -0700336 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(pCreateInfo->pNext);
337 if (raytracing_features && raytracing_features->rayTracingShaderGroupHandleCaptureReplayMixed &&
338 !raytracing_features->rayTracingShaderGroupHandleCaptureReplay) {
339 skip |= LogError(device, "VUID-VkPhysicalDeviceRayTracingFeaturesKHR-rayTracingShaderGroupHandleCaptureReplayMixed-03348",
340 "If rayTracingShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingShaderGroupHandleCaptureReplay "
341 "must also be VK_TRUE.");
342 }
Locke77fad1c2019-04-16 13:09:03 -0600343 auto vertex_attribute_divisor_features =
344 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600345 if (vertex_attribute_divisor_features && (!device_extensions.vk_ext_vertex_attribute_divisor)) {
346 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
347 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
348 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600349 }
350
Tony-LunarG28017bc2020-01-23 14:40:25 -0700351 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
352 if (vulkan_11_features) {
353 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
354 while (current) {
355 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
356 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
357 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
358 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
359 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
360 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700361 skip |= LogError(
362 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700363 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
364 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
365 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
366 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
367 break;
368 }
369 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
370 }
371 }
372
373 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
374 if (vulkan_12_features) {
375 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
376 while (current) {
377 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
378 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
379 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
380 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
381 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
382 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
383 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
384 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
385 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
386 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
387 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
388 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
389 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700390 skip |= LogError(
391 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700392 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
393 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
394 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
395 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
396 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
397 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
398 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
399 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
400 break;
401 }
402 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
403 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700404 // Check features are enabled if matching extension is passed in as well
405 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
406 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
407 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
408 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
409 skip |= LogError(
410 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
411 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
412 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
413 }
414 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
415 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
416 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
417 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
418 "is not VK_TRUE.",
419 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
420 }
421 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
422 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
423 skip |= LogError(
424 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
425 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
426 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
427 }
428 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
429 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
430 skip |= LogError(
431 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
432 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
433 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
434 }
435 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
436 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
437 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
438 skip |=
439 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
440 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
441 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
442 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
443 }
444 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700445 }
446
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600447 // Validate pCreateInfo->pQueueCreateInfos
448 if (pCreateInfo->pQueueCreateInfos) {
449 std::unordered_set<uint32_t> set;
450
451 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700452 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
453 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600454 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700455 skip |=
456 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
457 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
458 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
459 "index value.",
460 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600461 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700462 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
463 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
464 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
465 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600466 } else {
467 set.insert(requested_queue_family);
468 }
469
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700470 if (queue_create_info.pQueuePriorities != nullptr) {
471 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
472 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600473 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700474 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
475 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
476 "] (=%f) is not between 0 and 1 (inclusive).",
477 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600478 }
479 }
480 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700481
482 // Need to know if protectedMemory feature is passed in preCall to creating the device
483 VkBool32 protectedMemory = VK_FALSE;
484 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
485 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
486 if (protected_features) {
487 protectedMemory = protected_features->protectedMemory;
488 } else if (vulkan_11_features) {
489 protectedMemory = vulkan_11_features->protectedMemory;
490 }
491 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) {
492 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
493 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
494 "protectedMemory feature being set as well.");
495 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600496 }
497 }
498
sfricke-samsung30a57412020-05-15 21:14:54 -0700499 // feature dependencies for VK_KHR_variable_pointers
500 const auto *variable_pointers_features = lvl_find_in_chain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
501 VkBool32 variablePointers = VK_FALSE;
502 VkBool32 variablePointersStorageBuffer = VK_FALSE;
503 if (vulkan_11_features) {
504 variablePointers = vulkan_11_features->variablePointers;
505 variablePointersStorageBuffer = vulkan_11_features->variablePointersStorageBuffer;
506 } else if (variable_pointers_features) {
507 variablePointers = variable_pointers_features->variablePointers;
508 variablePointersStorageBuffer = variable_pointers_features->variablePointersStorageBuffer;
509 }
510 if ((variablePointers == VK_TRUE) && (variablePointersStorageBuffer == VK_FALSE)) {
511 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
512 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
513 }
514
sfricke-samsungfd76c342020-05-29 23:13:43 -0700515 // feature dependencies for VK_KHR_multiview
516 const auto *multiview_features = lvl_find_in_chain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
517 VkBool32 multiview = VK_FALSE;
518 VkBool32 multiviewGeometryShader = VK_FALSE;
519 VkBool32 multiviewTessellationShader = VK_FALSE;
520 if (vulkan_11_features) {
521 multiview = vulkan_11_features->multiview;
522 multiviewGeometryShader = vulkan_11_features->multiviewGeometryShader;
523 multiviewTessellationShader = vulkan_11_features->multiviewTessellationShader;
524 } else if (multiview_features) {
525 multiview = multiview_features->multiview;
526 multiviewGeometryShader = multiview_features->multiviewGeometryShader;
527 multiviewTessellationShader = multiview_features->multiviewTessellationShader;
528 }
529 if ((multiview == VK_FALSE) && (multiviewGeometryShader == VK_TRUE)) {
530 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
531 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
532 }
533 if ((multiview == VK_FALSE) && (multiviewTessellationShader == VK_TRUE)) {
534 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
535 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
536 }
537
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600538 return skip;
539}
540
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500541bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700542 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700543 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
544 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
545 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600546 }
547
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700548 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600549}
550
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700551bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500552 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100553 bool skip = false;
554
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600555 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700556 skip |=
557 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600558
559 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
560 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
561 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
562 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700563 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
564 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
565 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600566 }
567
568 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
569 // queueFamilyIndexCount uint32_t values
570 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700571 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
572 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
573 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
574 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600575 }
576 }
577
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700578 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
579 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
580 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
581 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
582 }
583
584 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
585 skip |=
586 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
587 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
588 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
589 }
590
591 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
592 skip |=
593 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
594 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
595 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
596 }
597
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600598 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
599 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
600 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
601 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700602 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
603 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
604 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600605 }
606 }
607
608 return skip;
609}
610
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700611bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500612 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600613 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600614
615 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600616 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
617 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
618 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
619 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700620 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
621 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
622 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600623 }
624
625 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
626 // queueFamilyIndexCount uint32_t values
627 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700628 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
629 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
630 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
631 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600632 }
633 }
634
Dave Houlton413a6782018-05-22 13:01:54 -0600635 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700636 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600637 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700638 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600639 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700640 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600641
Dave Houlton413a6782018-05-22 13:01:54 -0600642 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700643 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600644 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700645 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600646
Dave Houlton130c0212018-01-29 13:39:56 -0700647 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700648 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
649 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700650 skip |= LogError(
651 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600652 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
653 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700654 }
655
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600656 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100657 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
658 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700659 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
660 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
661 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600662 }
663
664 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100665 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
666 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700667 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
668 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
669 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
670 ") are not equal.",
671 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100672 }
673
674 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700675 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
676 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
677 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
678 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100679 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600680 }
681
682 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700683 skip |= LogError(
684 device, "VUID-VkImageCreateInfo-imageType-00957",
685 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600686 }
687 }
688
Dave Houlton130c0212018-01-29 13:39:56 -0700689 // 3D image may have only 1 layer
690 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700691 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
692 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700693 }
694
Dave Houlton130c0212018-01-29 13:39:56 -0700695 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
696 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
697 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
698 // At least one of the legal attachment bits must be set
699 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700700 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
701 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700702 }
703 // No flags other than the legal attachment bits may be set
704 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
705 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700706 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
707 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700708 }
709 }
710
Jeff Bolzef40fec2018-09-01 22:04:34 -0500711 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600712 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500713 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600714 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
715 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500716 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600717 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700718 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
719 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
720 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600721 }
722
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600723 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700724 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
725 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
726 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600727 }
728
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700729 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700730 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
731 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
732 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100733 }
734
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700735 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
736 skip |= LogError(
737 device, "VUID-VkImageCreateInfo-flags-01924",
738 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
739 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
740 }
741
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600742 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
743 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
744 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
745 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700746 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
747 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
748 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600749 }
750
751 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
752 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
753 // Linear tiling is unsupported
754 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700755 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700756 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
757 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600758 }
759
760 // Sparse 1D image isn't valid
761 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700762 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
763 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600764 }
765
766 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700767 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700768 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
769 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
770 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600771 }
772
773 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700774 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700775 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
776 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
777 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600778 }
779
780 // Multi-sample 2D image when device doesn't support it
781 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700782 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600783 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700784 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
785 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
786 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700787 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600788 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700789 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
790 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
791 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700792 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600793 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700794 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
795 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
796 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700797 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600798 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700799 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
800 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
801 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600802 }
803 }
804 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500805
Jeff Bolz9af91c52018-09-01 21:53:57 -0500806 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
807 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700808 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
809 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
810 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500811 }
812 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700813 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
814 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
815 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500816 }
817 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700818 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
819 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
820 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500821 }
822 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500823
824 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600825 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700826 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
827 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
828 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500829 }
830
Dave Houlton142c4cb2018-10-17 15:04:41 -0600831 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700832 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
833 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
834 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
835 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500836 }
837
Dave Houlton142c4cb2018-10-17 15:04:41 -0600838 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700839 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
840 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
841 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
842 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500843 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600844 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700845 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
846 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
847 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
848 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500849 }
850 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500851
sfricke-samsung8f658d42020-05-03 20:12:24 -0700852 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
853 (FormatHasDepth(pCreateInfo->format) == false)) {
854 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
855 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
856 "format must be a depth or depth/stencil format.");
857 }
858
Andrew Fobel3abeb992020-01-20 16:33:22 -0500859 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
860 if (image_stencil_struct != nullptr) {
861 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
862 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
863 // No flags other than the legal attachment bits may be set
864 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
865 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700866 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
867 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
868 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
869 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500870 }
871 }
872
873 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
874 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
875 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
876 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700877 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
878 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
879 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
880 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500881 }
882
883 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
884 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700885 LogError(device, "VUID-VkImageCreateInfo-format-02537",
886 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
887 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
888 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500889 }
890 }
891
892 if (!physical_device_features.shaderStorageImageMultisample &&
893 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
894 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
895 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700896 LogError(device, "VUID-VkImageCreateInfo-format-02538",
897 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
898 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
899 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500900 }
901
902 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
903 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700904 skip |= LogError(
905 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500906 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
907 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
908 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
909 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
910 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700911 skip |= LogError(
912 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500913 "vkCreateImage(): Depth-stencil image in which usage does not include "
914 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
915 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
916 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
917 }
918
919 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
920 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700921 skip |= LogError(
922 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500923 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
924 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
925 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
926 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
927 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700928 skip |= LogError(
929 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500930 "vkCreateImage(): Depth-stencil image in which usage does not include "
931 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
932 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
933 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
934 }
935 }
936 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700937
938 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
939 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
940 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
941 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
942 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
943 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700944
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -0700945 std::vector<uint64_t> image_create_drm_format_modifiers;
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700946 if (device_extensions.vk_ext_image_drm_format_modifier) {
947 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
948 const auto drm_format_mod_explict =
949 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
950 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
951 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
952 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
953 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
954 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
955 "either VkImageDrmFormatModifierListCreateInfoEXT or "
956 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -0700957 } else if (drm_format_mod_list != nullptr) {
958 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
959 } else if (drm_format_mod_list != nullptr) {
960 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
961 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
962 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700963 }
964 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
965 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
966 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
967 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
968 "in the pNext chain");
969 }
970 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +0200971
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -0700972 static const uint64_t DRM_FORMAT_MOD_LINEAR = 0;
973 bool image_create_maybe_linear = false;
974 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
975 image_create_maybe_linear = true;
976 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
977 image_create_maybe_linear = false;
978 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
979 image_create_maybe_linear =
980 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
981 DRM_FORMAT_MOD_LINEAR) != image_create_drm_format_modifiers.end());
982 }
983
984 // If multi-sample, validate type, usage, tiling and mip levels.
985 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
986 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
987 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
988 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
989 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
990 }
991
992 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
993 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
994 image_create_maybe_linear)) {
995 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
996 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
997 }
998
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +0200999 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1000 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1001 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1002 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1003 "imageType must be VK_IMAGE_TYPE_2D.");
1004 }
1005 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1006 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1007 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1008 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1009 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001010 }
1011 if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
1012 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1013 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1014 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1015 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1016 }
1017 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1018 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1019 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1020 "imageType must be VK_IMAGE_TYPE_2D.");
1021 }
1022 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
1023 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1024 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1025 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1026 }
1027 if (pCreateInfo->mipLevels != 1) {
1028 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1029 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1030 pCreateInfo->mipLevels);
1031 }
1032 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001033
1034 const auto swapchain_create_info = lvl_find_in_chain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
1035 if (swapchain_create_info != nullptr) {
1036 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1037 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1038 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1039 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1040 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1041 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1042
1043 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1044 // also implicitly forces the check above that extent.depth is 1
1045 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1046 string_VkImageType(pCreateInfo->imageType));
1047 }
1048 if (pCreateInfo->mipLevels != 1) {
1049 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1050 pCreateInfo->mipLevels);
1051 }
1052 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1053 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1054 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1055 }
1056 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1057 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1058 base_message, string_VkImageTiling(pCreateInfo->tiling));
1059 }
1060 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1061 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1062 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1063 }
1064 const VkImageCreateFlags valid_flags =
1065 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
1066 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR);
1067 if ((pCreateInfo->flags & ~valid_flags) != 0) {
1068 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
1069 pCreateInfo->flags);
1070 }
1071 }
1072 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001073 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001074
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001075 return skip;
1076}
1077
Jeff Bolz99e3f632020-03-24 22:59:22 -05001078bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1079 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1080 bool skip = false;
1081
1082 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001083 // Validate feature set if using CUBE_ARRAY
1084 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1085 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1086 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1087 "enabling the imageCubeArray feature.");
1088 }
1089
Jeff Bolz99e3f632020-03-24 22:59:22 -05001090 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1091 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1092 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001093 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001094 pCreateInfo->subresourceRange.layerCount);
1095 }
1096 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001097 skip |= LogError(
1098 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1099 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1100 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001101 }
1102 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001103
1104 auto astc_decode_mode = lvl_find_in_chain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
1105 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1106 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1107 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1108 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1109 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1110 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1111 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1112 }
1113 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1114 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1115 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1116 "not an ASTC format.",
1117 string_VkFormat(pCreateInfo->format));
1118 }
1119 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001120
1121 auto ycbcr_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
1122 if (ycbcr_conversion != nullptr) {
1123 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1124 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1125 skip |= LogError(
1126 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1127 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1128 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1129 "r swizzle = %s\n"
1130 "g swizzle = %s\n"
1131 "b swizzle = %s\n"
1132 "a swizzle = %s\n",
1133 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1134 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1135 }
1136 }
1137 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001138 }
1139 return skip;
1140}
1141
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001142bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001143 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001144 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001145
1146 // Note: for numerical correctness
1147 // - float comparisons should expect NaN (comparison always false).
1148 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1149
1150 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001151 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001152 if (v1_f <= 0.0f) return true;
1153
1154 float intpart;
1155 const float fract = modff(v1_f, &intpart);
1156
1157 assert(std::numeric_limits<float>::radix == 2);
1158 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1159 if (intpart >= u32_max_plus1) return false;
1160
1161 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
1162 if (v1_u32 < v2_u32)
1163 return true;
1164 else if (v1_u32 == v2_u32 && fract == 0.0f)
1165 return true;
1166 else
1167 return false;
1168 };
1169
1170 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1171 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1172 return (v1_f <= v2_f);
1173 };
1174
1175 // width
1176 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001177 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001178
1179 if (!(viewport.width > 0.0f)) {
1180 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001181 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1182 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001183 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1184 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001185 skip |= LogError(object, "VUID-VkViewport-width-01771",
1186 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1187 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001188 }
1189
1190 // height
1191 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001192 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001193 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001194
1195 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1196 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001197 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1198 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001199 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1200 height_healthy = false;
1201
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001202 skip |= LogError(object, "VUID-VkViewport-height-01773",
1203 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1204 ").",
1205 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001206 }
1207
1208 // x
1209 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001210 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001211 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001212 skip |= LogError(object, "VUID-VkViewport-x-01774",
1213 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1214 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001215 }
1216
1217 // x + width
1218 if (x_healthy && width_healthy) {
1219 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001220 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001221 skip |= LogError(
1222 object, "VUID-VkViewport-x-01232",
1223 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1224 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1225 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001226 }
1227 }
1228
1229 // y
1230 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001231 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001232 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001233 skip |= LogError(object, "VUID-VkViewport-y-01775",
1234 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1235 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001236 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001237 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001238 skip |= LogError(object, "VUID-VkViewport-y-01776",
1239 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1240 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001241 }
1242
1243 // y + height
1244 if (y_healthy && height_healthy) {
1245 const float boundary = viewport.y + viewport.height;
1246
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001247 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001248 skip |= LogError(object, "VUID-VkViewport-y-01233",
1249 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1250 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1251 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001252 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001253 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001254 LogError(object, "VUID-VkViewport-y-01777",
1255 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1256 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1257 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001258 }
1259 }
1260
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001261 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001262 // minDepth
1263 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001264 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001265
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001266 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1267 "[0.0, 1.0] range.",
1268 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001269 }
1270
1271 // maxDepth
1272 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001273 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001274
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001275 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1276 "[0.0, 1.0] range.",
1277 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001278 }
1279 }
1280
1281 return skip;
1282}
1283
Dave Houlton142c4cb2018-10-17 15:04:41 -06001284struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001285 VkShadingRatePaletteEntryNV shadingRate;
1286 uint32_t width;
1287 uint32_t height;
1288};
1289
1290// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -06001291static SampleOrderInfo sampleOrderInfos[] = {
1292 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1293 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1294 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1295 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1296 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1297 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001298};
1299
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001300bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001301 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001302
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001303 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001304 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001305 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001306 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001307 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001308 break;
1309 }
1310 }
1311
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001312 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001313 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1314 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1315 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001316 return skip;
1317 }
1318
Dave Houlton142c4cb2018-10-17 15:04:41 -06001319 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001320 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001321 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1322 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1323 ") must "
1324 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1325 "is set in framebufferNoAttachmentsSampleCounts.",
1326 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001327 }
1328
Jeff Bolz9af91c52018-09-01 21:53:57 -05001329 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001330 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1331 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1332 ") must "
1333 "be equal to the product of sampleCount (=%" PRIu32
1334 "), the fragment width for shadingRate "
1335 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1336 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001337 }
1338
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001339 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001340 skip |= LogError(
1341 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001342 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1343 ") must "
1344 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001345 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001346 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001347
1348 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001349 // the first width*height*sampleCount bits to all be set. Note: There is no
1350 // guarantee that 64 bits is enough, but practically it's unlikely for an
1351 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001352 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001353 uint64_t sampleLocationsMask = 0;
1354 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1355 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1356 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001357 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1358 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001359 }
1360 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001361 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1362 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001363 }
1364 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001365 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1366 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001367 }
1368 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1369 sampleLocationsMask |= 1ULL << idx;
1370 }
1371
1372 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1373 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001374 skip |= LogError(
1375 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001376 "The array pSampleLocations must contain exactly one entry for "
1377 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001378 }
1379
1380 return skip;
1381}
1382
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001383bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1384 uint32_t createInfoCount,
1385 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1386 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001387 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001388 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001389
1390 if (pCreateInfos != nullptr) {
1391 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001392 bool has_dynamic_viewport = false;
1393 bool has_dynamic_scissor = false;
1394 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001395 bool has_dynamic_depth_bias = false;
1396 bool has_dynamic_blend_constant = false;
1397 bool has_dynamic_depth_bounds = false;
1398 bool has_dynamic_stencil_compare = false;
1399 bool has_dynamic_stencil_write = false;
1400 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001401 bool has_dynamic_viewport_w_scaling_nv = false;
1402 bool has_dynamic_discard_rectangle_ext = false;
1403 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001404 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001405 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001406 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001407 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001408 bool has_dynamic_cull_mode = false;
1409 bool has_dynamic_front_face = false;
1410 bool has_dynamic_primitive_topology = false;
1411 bool has_dynamic_viewport_with_count = false;
1412 bool has_dynamic_scissor_with_count = false;
1413 bool has_dynamic_vertex_input_binding_stride = false;
1414 bool has_dynamic_depth_test_enable = false;
1415 bool has_dynamic_depth_write_enable = false;
1416 bool has_dynamic_depth_compare_op = false;
1417 bool has_dynamic_depth_bounds_test_enable = false;
1418 bool has_dynamic_stencil_test_enable = false;
1419 bool has_dynamic_stencil_op = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001420 if (pCreateInfos[i].pDynamicState != nullptr) {
1421 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1422 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1423 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001424 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1425 if (has_dynamic_viewport == true) {
1426 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1427 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1428 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1429 i);
1430 }
1431 has_dynamic_viewport = true;
1432 }
1433 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1434 if (has_dynamic_scissor == true) {
1435 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1436 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1437 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1438 i);
1439 }
1440 has_dynamic_scissor = true;
1441 }
1442 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1443 if (has_dynamic_line_width == true) {
1444 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1445 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1446 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1447 i);
1448 }
1449 has_dynamic_line_width = true;
1450 }
1451 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1452 if (has_dynamic_depth_bias == true) {
1453 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1454 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1455 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1456 i);
1457 }
1458 has_dynamic_depth_bias = true;
1459 }
1460 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1461 if (has_dynamic_blend_constant == true) {
1462 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1463 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1464 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1465 i);
1466 }
1467 has_dynamic_blend_constant = true;
1468 }
1469 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1470 if (has_dynamic_depth_bounds == true) {
1471 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1472 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1473 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1474 i);
1475 }
1476 has_dynamic_depth_bounds = true;
1477 }
1478 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1479 if (has_dynamic_stencil_compare == true) {
1480 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1481 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1482 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1483 i);
1484 }
1485 has_dynamic_stencil_compare = true;
1486 }
1487 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1488 if (has_dynamic_stencil_write == true) {
1489 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1490 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1491 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1492 i);
1493 }
1494 has_dynamic_stencil_write = true;
1495 }
1496 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1497 if (has_dynamic_stencil_reference == true) {
1498 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1499 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1500 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1501 i);
1502 }
1503 has_dynamic_stencil_reference = true;
1504 }
1505 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1506 if (has_dynamic_viewport_w_scaling_nv == true) {
1507 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1508 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1509 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1510 i);
1511 }
1512 has_dynamic_viewport_w_scaling_nv = true;
1513 }
1514 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1515 if (has_dynamic_discard_rectangle_ext == true) {
1516 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1517 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1518 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1519 i);
1520 }
1521 has_dynamic_discard_rectangle_ext = true;
1522 }
1523 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1524 if (has_dynamic_sample_locations_ext == true) {
1525 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1526 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1527 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1528 i);
1529 }
1530 has_dynamic_sample_locations_ext = true;
1531 }
1532 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1533 if (has_dynamic_exclusive_scissor_nv == true) {
1534 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1535 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1536 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1537 i);
1538 }
1539 has_dynamic_exclusive_scissor_nv = true;
1540 }
1541 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1542 if (has_dynamic_shading_rate_palette_nv == true) {
1543 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1544 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1545 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1546 i);
1547 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001548 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001549 }
1550 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1551 if (has_dynamic_viewport_course_sample_order_nv == true) {
1552 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1553 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1554 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1555 i);
1556 }
1557 has_dynamic_viewport_course_sample_order_nv = true;
1558 }
1559 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1560 if (has_dynamic_line_stipple == true) {
1561 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1562 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1563 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1564 i);
1565 }
1566 has_dynamic_line_stipple = true;
1567 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001568 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1569 if (has_dynamic_cull_mode) {
1570 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1571 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1572 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1573 i);
1574 }
1575 has_dynamic_cull_mode = true;
1576 }
1577 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1578 if (has_dynamic_front_face) {
1579 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1580 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1581 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1582 i);
1583 }
1584 has_dynamic_front_face = true;
1585 }
1586 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1587 if (has_dynamic_primitive_topology) {
1588 skip |= LogError(
1589 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1590 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1591 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1592 i);
1593 }
1594 has_dynamic_primitive_topology = true;
1595 }
1596 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1597 if (has_dynamic_viewport_with_count) {
1598 skip |= LogError(
1599 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1600 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1601 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1602 i);
1603 }
1604 has_dynamic_viewport_with_count = true;
1605 }
1606 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1607 if (has_dynamic_scissor_with_count) {
1608 skip |= LogError(
1609 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1610 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1611 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1612 i);
1613 }
1614 has_dynamic_scissor_with_count = true;
1615 }
1616 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1617 if (has_dynamic_vertex_input_binding_stride) {
1618 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1619 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1620 "listed twice in the "
1621 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1622 i);
1623 }
1624 has_dynamic_vertex_input_binding_stride = true;
1625 }
1626 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1627 if (has_dynamic_depth_test_enable) {
1628 skip |= LogError(
1629 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1630 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1631 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1632 i);
1633 }
1634 has_dynamic_depth_test_enable = true;
1635 }
1636 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1637 if (has_dynamic_depth_write_enable) {
1638 skip |= LogError(
1639 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1640 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1641 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1642 i);
1643 }
1644 has_dynamic_depth_write_enable = true;
1645 }
1646 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1647 if (has_dynamic_depth_compare_op) {
1648 skip |=
1649 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1650 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1651 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1652 i);
1653 }
1654 has_dynamic_depth_compare_op = true;
1655 }
1656 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1657 if (has_dynamic_depth_bounds_test_enable) {
1658 skip |= LogError(
1659 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1660 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1661 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1662 i);
1663 }
1664 has_dynamic_depth_bounds_test_enable = true;
1665 }
1666 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1667 if (has_dynamic_stencil_test_enable) {
1668 skip |= LogError(
1669 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1670 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1671 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1672 i);
1673 }
1674 has_dynamic_stencil_test_enable = true;
1675 }
1676 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1677 if (has_dynamic_stencil_op) {
1678 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1679 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1680 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1681 i);
1682 }
1683 has_dynamic_stencil_op = true;
1684 }
Petr Kraus299ba622017-11-24 03:09:03 +01001685 }
1686 }
1687
Peter Chen85366392019-05-14 15:20:11 -04001688 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1689 if ((feedback_struct != nullptr) &&
1690 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001691 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1692 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1693 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1694 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1695 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001696 }
1697
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001698 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001699
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001700 // Collect active stages and other information
1701 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001702 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001703 bool has_eval = false;
1704 bool has_control = false;
1705 if (pCreateInfos[i].pStages != nullptr) {
1706 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1707 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1708
1709 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1710 has_control = true;
1711 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1712 has_eval = true;
1713 }
1714
1715 skip |= validate_string(
1716 "vkCreateGraphicsPipelines",
1717 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1718 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1719 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001720 }
1721
1722 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1723 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1724 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1725 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1726 pCreateInfos[i].pTessellationState,
1727 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1728 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1729
1730 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1731 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1732
1733 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1734 "VkPipelineTessellationDomainOriginStateCreateInfo",
1735 pCreateInfos[i].pTessellationState->pNext,
1736 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1737 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001738 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1739 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001740
1741 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1742 pCreateInfos[i].pTessellationState->flags,
1743 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1744 }
1745
1746 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1747 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1748 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1749 pCreateInfos[i].pInputAssemblyState,
1750 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1751 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1752
1753 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1754 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001755 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001756
1757 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1758 pCreateInfos[i].pInputAssemblyState->flags,
1759 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1760
1761 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1762 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1763 pCreateInfos[i].pInputAssemblyState->topology,
1764 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1765
1766 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1767 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1768 }
1769
1770 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001771 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001772
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001773 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001774 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1775 "vkCreateGraphicsPipelines: pararameter "
1776 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1777 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001778 }
1779
1780 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1781 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1782 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1783 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1784 pCreateInfos[i].pVertexInputState->pNext, 1,
1785 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001786 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1787 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001788 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1789 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001790 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001791 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1792 skip |=
1793 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1794 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1795 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1796 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1797 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1798
1799 skip |= validate_array(
1800 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1801 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1802 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1803 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1804
1805 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1806 for (uint32_t vertexBindingDescriptionIndex = 0;
1807 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1808 ++vertexBindingDescriptionIndex) {
1809 skip |= validate_ranged_enum(
1810 "vkCreateGraphicsPipelines",
1811 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1812 AllVkVertexInputRateEnums,
1813 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1814 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1815 }
1816 }
1817
1818 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1819 for (uint32_t vertexAttributeDescriptionIndex = 0;
1820 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1821 ++vertexAttributeDescriptionIndex) {
1822 skip |= validate_ranged_enum(
1823 "vkCreateGraphicsPipelines",
1824 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1825 AllVkFormatEnums,
1826 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1827 "VUID-VkVertexInputAttributeDescription-format-parameter");
1828 }
1829 }
1830
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001831 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001832 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1833 "vkCreateGraphicsPipelines: pararameter "
1834 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1835 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1836 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001837 }
1838
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001839 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001840 skip |=
1841 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1842 "vkCreateGraphicsPipelines: pararameter "
1843 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1844 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1845 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001846 }
1847
1848 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001849 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1850 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001851 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1852 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001853 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1854 "vkCreateGraphicsPipelines: parameter "
1855 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1856 "(%" PRIu32 ") is not distinct.",
1857 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001858 }
1859 vertex_bindings.insert(vertex_bind_desc.binding);
1860
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001861 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001862 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1863 "vkCreateGraphicsPipelines: parameter "
1864 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1865 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1866 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001867 }
1868
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001869 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001870 skip |=
1871 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1872 "vkCreateGraphicsPipelines: parameter "
1873 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1874 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1875 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001876 }
1877 }
1878
Peter Kohautc7d9d392018-07-15 00:34:07 +02001879 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001880 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1881 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001882 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1883 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001884 skip |= LogError(
1885 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001886 "vkCreateGraphicsPipelines: parameter "
1887 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1888 i, d, vertex_attrib_desc.location);
1889 }
1890 attribute_locations.insert(vertex_attrib_desc.location);
1891
1892 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1893 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001894 skip |= LogError(
1895 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001896 "vkCreateGraphicsPipelines: parameter "
1897 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1898 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1899 i, d, vertex_attrib_desc.binding, i);
1900 }
1901
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001902 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001903 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1904 "vkCreateGraphicsPipelines: parameter "
1905 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1906 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1907 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001908 }
1909
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001910 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001911 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1912 "vkCreateGraphicsPipelines: parameter "
1913 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1914 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1915 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001916 }
1917
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001918 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001919 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1920 "vkCreateGraphicsPipelines: parameter "
1921 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1922 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1923 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001924 }
1925 }
1926 }
1927
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001928 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1929 if (has_control && has_eval) {
1930 if (pCreateInfos[i].pTessellationState == nullptr) {
1931 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1932 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1933 "shader stage and a tessellation evaluation shader stage, "
1934 "pCreateInfos[%d].pTessellationState must not be NULL.",
1935 i, i);
1936 } else {
1937 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1938 skip |= validate_struct_pnext(
1939 "vkCreateGraphicsPipelines",
1940 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1941 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1942 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1943 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001944
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001945 skip |= validate_reserved_flags(
1946 "vkCreateGraphicsPipelines",
1947 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1948 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001949
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001950 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1951 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1952 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1953 "vkCreateGraphicsPipelines: invalid parameter "
1954 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1955 "should be >0 and <=%u.",
1956 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1957 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001958 }
1959 }
1960 }
1961
1962 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1963 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1964 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1965 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001966 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1967 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1968 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1969 "].pViewportState (=NULL) is not a valid pointer.",
1970 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001971 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001972 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1973
1974 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001975 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1976 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1977 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1978 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001979 }
1980
Petr Krausa6103552017-11-16 21:21:58 +01001981 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1982 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001983 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1984 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001985 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1986 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001987 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001988 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001989 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001990 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001991 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001992 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1993 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001994 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001995 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1996 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001997
1998 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001999 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002000 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002001 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002002
Dave Houlton142c4cb2018-10-17 15:04:41 -06002003 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
2004 pCreateInfos[i].pViewportState->pNext);
2005 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
2006 pCreateInfos[i].pViewportState->pNext);
2007 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
2008 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002009 const auto vp_swizzle_struct =
2010 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002011 const auto vp_w_scaling_struct =
2012 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002013
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002014 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002015 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002016 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2017 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2018 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2019 ") is not 1.",
2020 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002021 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002022
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002023 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002024 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2025 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2026 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2027 ") is not 1.",
2028 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002029 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002030
Dave Houlton142c4cb2018-10-17 15:04:41 -06002031 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2032 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002033 skip |= LogError(
2034 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2035 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2036 "disabled, but pCreateInfos[%" PRIu32
2037 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2038 ") is not 1.",
2039 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002040 }
2041
Jeff Bolz9af91c52018-09-01 21:53:57 -05002042 if (shading_rate_image_struct &&
2043 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002044 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2045 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2046 "disabled, but pCreateInfos[%" PRIu32
2047 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2048 ") is neither 0 nor 1.",
2049 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002050 }
2051
Petr Krausa6103552017-11-16 21:21:58 +01002052 } else { // multiViewport enabled
2053 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002054 if (!has_dynamic_viewport_with_count) {
2055 skip |= LogError(
2056 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2057 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2058 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002059 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002060 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2061 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2062 "].pViewportState->viewportCount (=%" PRIu32
2063 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2064 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002065 } else if (has_dynamic_viewport_with_count) {
2066 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2067 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2068 "].pViewportState->viewportCount (=%" PRIu32
2069 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2070 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002071 }
Petr Krausa6103552017-11-16 21:21:58 +01002072
2073 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002074 if (!has_dynamic_scissor_with_count) {
2075 skip |= LogError(
2076 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2077 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2078 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002079 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002080 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2081 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2082 "].pViewportState->scissorCount (=%" PRIu32
2083 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2084 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002085 } else if (has_dynamic_scissor_with_count) {
2086 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2087 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2088 "].pViewportState->scissorCount (=%" PRIu32
2089 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2090 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002091 }
2092 }
2093
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002094 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002095 skip |=
2096 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2097 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2098 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2099 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002100 }
2101
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002102 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002103 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2104 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2105 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2106 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2107 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002108 }
2109
Piers Daniell39842ee2020-07-10 16:42:33 -06002110 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2111 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002112 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2113 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2114 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2115 "].pViewportState->viewportCount (=%" PRIu32 ").",
2116 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002117 }
2118
Dave Houlton142c4cb2018-10-17 15:04:41 -06002119 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002120 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002121 skip |=
2122 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2123 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2124 ") must be zero or identical to pCreateInfos[%" PRIu32
2125 "].pViewportState->viewportCount (=%" PRIu32 ").",
2126 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002127 }
2128
Dave Houlton142c4cb2018-10-17 15:04:41 -06002129 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002130 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002131 skip |= LogError(
2132 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002133 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2134 "] "
2135 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2136 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2137 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002138 }
2139
Petr Krausa6103552017-11-16 21:21:58 +01002140 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002141 skip |= LogError(
2142 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002143 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2144 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002145 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2146 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002147 }
2148
2149 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002150 skip |= LogError(
2151 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002152 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2153 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002154 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2155 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002156 }
2157
Jeff Bolz3e71f782018-08-29 23:15:45 -05002158 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002159 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2160 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2161 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002162 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002163 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2164 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2165 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2166 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002167 }
2168
Jeff Bolz9af91c52018-09-01 21:53:57 -05002169 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002170 shading_rate_image_struct->viewportCount > 0 &&
2171 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002172 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002173 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002174 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002175 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2176 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002177 i, i);
2178 }
2179
Chris Mayer328d8212018-12-11 14:16:18 +01002180 if (vp_swizzle_struct) {
2181 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002182 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2183 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2184 " does "
2185 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2186 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002187 }
2188 }
2189
Petr Krausb3fcdb42018-01-09 22:09:09 +01002190 // validate the VkViewports
2191 if (!has_dynamic_viewport && viewport_state.pViewports) {
2192 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2193 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002194 const char *fn_name = "vkCreateGraphicsPipelines";
2195 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2196 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2197 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002198 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002199 }
2200 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002201
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002202 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002203 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2204 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2205 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2206 "VK_NV_clip_space_w_scaling extension is not enabled.",
2207 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002208 }
2209
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002210 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002211 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2212 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2213 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2214 "VK_EXT_discard_rectangles extension is not enabled.",
2215 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002216 }
2217
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002218 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002219 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2220 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2221 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2222 "VK_EXT_sample_locations extension is not enabled.",
2223 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002224 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002225
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002226 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002227 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2228 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2229 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2230 "VK_NV_scissor_exclusive extension is not enabled.",
2231 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002232 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002233
2234 if (coarse_sample_order_struct &&
2235 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2236 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002237 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2238 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2239 "] "
2240 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2241 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2242 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002243 }
2244
2245 if (coarse_sample_order_struct) {
2246 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002247 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002248 }
2249 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002250
2251 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2252 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002253 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2254 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2255 "] "
2256 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2257 ") "
2258 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2259 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002260 }
2261 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002262 skip |= LogError(
2263 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002264 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2265 "] "
2266 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2267 i);
2268 }
2269 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002270 }
2271
2272 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002273 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2274 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2275 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2276 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002277 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002278 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002279 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002280 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2281 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002282 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002283 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002284 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002285 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002286 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002287 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002288 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002289 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2290 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002291
2292 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002293 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002294 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002295 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002296
2297 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002298 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002299 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2300 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2301
2302 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002303 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002304 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2305 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002306 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002307 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002308
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002309 skip |= validate_flags(
2310 "vkCreateGraphicsPipelines",
2311 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2312 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002313 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002314
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002315 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002316 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002317 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2318 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2319
2320 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002321 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002322 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2323 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2324
2325 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002326 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002327 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2328 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2329 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002330 }
John Zulauf7acac592017-11-06 11:15:53 -07002331 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002332 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002333 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2334 "vkCreateGraphicsPipelines(): parameter "
2335 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2336 i);
John Zulauf7acac592017-11-06 11:15:53 -07002337 }
2338 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2339 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2340 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002341 skip |= LogError(
2342 device,
2343
Dave Houlton413a6782018-05-22 13:01:54 -06002344 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002345 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002346 }
2347 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002348
2349 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
2350 pCreateInfos[i].pRasterizationState->pNext);
2351
2352 if (line_state) {
2353 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2354 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2355 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2356 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002357 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2358 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2359 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2360 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002361 }
2362 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2363 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002364 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2365 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2366 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2367 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002368 }
2369 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2370 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002371 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2372 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2373 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2374 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002375 }
2376 }
2377 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2378 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2379 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002380 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2381 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2382 "range [1,256].",
2383 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002384 }
2385 }
2386 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002387 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002388 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2389 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002390 skip |=
2391 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2392 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2393 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2394 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002395 }
2396 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2397 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002398 skip |=
2399 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2400 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2401 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2402 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002403 }
2404 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2405 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002406 skip |=
2407 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2408 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2409 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2410 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002411 }
2412 if (line_state->stippledLineEnable) {
2413 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2414 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002415 skip |=
2416 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2417 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2418 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2419 "stippledRectangularLines feature.",
2420 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002421 }
2422 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2423 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002424 skip |=
2425 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2426 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2427 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2428 "stippledBresenhamLines feature.",
2429 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002430 }
2431 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2432 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002433 skip |=
2434 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2435 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2436 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2437 "stippledSmoothLines feature.",
2438 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002439 }
2440 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2441 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002442 skip |=
2443 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2444 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2445 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2446 "stippledRectangularLines and strictLines features.",
2447 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002448 }
2449 }
2450 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002451 }
2452
Petr Krause91f7a12017-12-14 20:57:36 +01002453 bool uses_color_attachment = false;
2454 bool uses_depthstencil_attachment = false;
2455 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002456 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002457 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2458 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002459 const auto &subpasses_uses = subpasses_uses_it->second;
2460 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
2461 uses_color_attachment = true;
2462 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
2463 uses_depthstencil_attachment = true;
2464 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002465 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002466 }
2467
2468 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002469 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002470 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002471 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002472 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002473 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002474
2475 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002476 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002477 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002478 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002479
2480 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002481 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002482 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2483 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2484
2485 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002486 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002487 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2488 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2489
2490 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002491 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002492 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2493 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002494 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002495
2496 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002497 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002498 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2499 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2500
2501 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002502 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002503 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2504 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2505
2506 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002507 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002508 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2509 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002510 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002511
2512 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002513 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002514 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2515 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002516 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002517
2518 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002519 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002520 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2521 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002522 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002523
2524 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002525 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002526 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2527 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002528 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002529
2530 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002531 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002532 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2533 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002534 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002535
2536 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002537 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002538 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2539 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002540 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002541
2542 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002543 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002544 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2545 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002546 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002547
2548 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002549 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002550 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2551 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002552 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002553
2554 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002555 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002556 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2557 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2558 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002559 }
2560 }
2561
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002562 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2563 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2564
Petr Krause91f7a12017-12-14 20:57:36 +01002565 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002566 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2567 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2568 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2569 pCreateInfos[i].pColorBlendState,
2570 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2571 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2572
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002573 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002574 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002575 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2576 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2577 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002578 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002579 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2580 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002581
2582 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002583 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002584 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002585 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002586
2587 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002588 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002589 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2590 pCreateInfos[i].pColorBlendState->logicOpEnable);
2591
2592 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002593 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002594 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2595 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002596 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002597 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002598
2599 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2600 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2601 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002602 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002603 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2604 ParameterName::IndexVector{i, attachmentIndex}),
2605 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2606
2607 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002608 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002609 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2610 ParameterName::IndexVector{i, attachmentIndex}),
2611 "VkBlendFactor", AllVkBlendFactorEnums,
2612 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002613 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002614
2615 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002616 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002617 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2618 ParameterName::IndexVector{i, attachmentIndex}),
2619 "VkBlendFactor", AllVkBlendFactorEnums,
2620 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002621 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002622
2623 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002624 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002625 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2626 ParameterName::IndexVector{i, attachmentIndex}),
2627 "VkBlendOp", AllVkBlendOpEnums,
2628 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002629 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002630
2631 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002632 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002633 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2634 ParameterName::IndexVector{i, attachmentIndex}),
2635 "VkBlendFactor", AllVkBlendFactorEnums,
2636 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002637 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002638
2639 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002640 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002641 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2642 ParameterName::IndexVector{i, attachmentIndex}),
2643 "VkBlendFactor", AllVkBlendFactorEnums,
2644 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002645 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002646
2647 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002648 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002649 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2650 ParameterName::IndexVector{i, attachmentIndex}),
2651 "VkBlendOp", AllVkBlendOpEnums,
2652 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002653 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002654
2655 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002656 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002657 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2658 ParameterName::IndexVector{i, attachmentIndex}),
2659 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2660 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002661 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002662 }
2663 }
2664
2665 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002666 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002667 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2668 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2669 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002670 }
2671
2672 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2673 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2674 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002675 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002676 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002677 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2678 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002679 }
2680 }
2681 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002682
Petr Kraus9752aae2017-11-24 03:05:50 +01002683 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2684 if (pCreateInfos[i].basePipelineIndex != -1) {
2685 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002686 skip |=
2687 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002688 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002689 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002690 "and pCreateInfos->basePipelineIndex is not -1.",
2691 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002692 }
2693 }
2694
Petr Kraus9752aae2017-11-24 03:05:50 +01002695 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2696 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002697 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002698 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002699 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002700 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2701 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002702 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002703 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002704 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002705 skip |=
2706 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2707 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2708 "index into the pCreateInfos array, of size %d.",
2709 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002710 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002711 }
2712 }
2713
sfricke-samsung898cf222020-05-15 23:10:19 -07002714 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2715 skip |= LogError(
2716 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2717 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE",
2718 i);
2719 }
2720
Petr Kraus9752aae2017-11-24 03:05:50 +01002721 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002722 if (!device_extensions.vk_nv_fill_rectangle) {
2723 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2724 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002725 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2726 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2727 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2728 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002729 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2730 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07002731 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002732 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002733 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2734 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2735 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002736 }
2737 } else {
2738 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2739 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2740 (physical_device_features.fillModeNonSolid == false)) {
2741 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002742 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2743 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002744 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2745 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2746 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002747 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002748 }
Petr Kraus299ba622017-11-24 03:09:03 +01002749
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002750 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002751 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002752 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2753 "The line width state is static (pCreateInfos[%" PRIu32
2754 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2755 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2756 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2757 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002758 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002759 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002760 }
2761 }
2762
2763 return skip;
2764}
2765
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002766bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2767 uint32_t createInfoCount,
2768 const VkComputePipelineCreateInfo *pCreateInfos,
2769 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002770 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002771 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002772 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002773 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002774 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002775 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002776 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2777 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002778 skip |=
2779 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2780 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2781 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2782 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002783 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002784
2785 // Make sure compute stage is selected
2786 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002787 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2788 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2789 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002790 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002791 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002792 return skip;
2793}
2794
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002795bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002796 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002797 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002798
2799 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002800 const auto &features = physical_device_features;
2801 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002802
John Zulauf71968502017-10-26 13:51:15 -06002803 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2804 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002805 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2806 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2807 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2808 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002809 }
2810
2811 // Anistropy cannot be enabled in sampler unless enabled as a feature
2812 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002813 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2814 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2815 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002816 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002817 }
John Zulauf71968502017-10-26 13:51:15 -06002818
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002819 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2820 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002821 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2822 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2823 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2824 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002825 }
2826 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002827 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2828 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2829 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2830 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002831 }
2832 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002833 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2834 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2835 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2836 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002837 }
2838 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2839 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2840 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2841 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002842 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2843 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2844 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2845 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2846 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2847 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002848 }
2849 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002850 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2851 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2852 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002853 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002854 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002855 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2856 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2857 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002858 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002859 }
2860
2861 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2862 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002863 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2864 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07002865 const auto *sampler_reduction = lvl_find_in_chain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
2866 if (sampler_reduction != nullptr) {
2867 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
2868 skip |= LogError(
2869 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
2870 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
2871 }
2872 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002873 }
2874
2875 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2876 // valid VkBorderColor value
2877 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2878 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2879 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002880 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2881 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002882 }
2883
2884 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2885 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002886 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002887 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2888 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2889 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002890 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002891 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2892 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2893 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002894 }
John Zulauf275805c2017-10-26 15:34:49 -06002895
2896 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002897 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002898 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2899 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002900 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2901 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2902 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002903 }
2904 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002905
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002906 // Check for valid Lod range
2907 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002908 skip |=
2909 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2910 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002911 }
2912
2913 // Check mipLodBias to device limit
2914 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002915 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2916 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2917 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002918 }
2919
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002920 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2921 if (sampler_conversion != nullptr) {
2922 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2923 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2924 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2925 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002926 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002927 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002928 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2929 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2930 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2931 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2932 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2933 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2934 }
2935 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02002936
2937 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
2938 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
2939 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
2940 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2941 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2942 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
2943 }
2944 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
2945 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
2946 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2947 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2948 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
2949 }
2950 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
2951 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
2952 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2953 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
2954 pCreateInfo->minLod, pCreateInfo->maxLod);
2955 }
2956 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2957 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
2958 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2959 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
2960 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
2961 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2962 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
2963 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
2964 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2965 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
2966 }
2967 if (pCreateInfo->anisotropyEnable) {
2968 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
2969 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2970 "pCreateInfo->anisotropyEnable must be VK_FALSE");
2971 }
2972 if (pCreateInfo->compareEnable) {
2973 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
2974 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2975 "pCreateInfo->compareEnable must be VK_FALSE");
2976 }
2977 if (pCreateInfo->unnormalizedCoordinates) {
2978 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
2979 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2980 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
2981 }
2982 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002983 }
2984
Tony-LunarG7337b312020-04-15 16:40:25 -06002985 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
2986 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
2987 if (!device_extensions.vk_ext_custom_border_color) {
2988 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2989 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
2990 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
2991 }
2992 auto custom_create_info = lvl_find_in_chain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
2993 if (!custom_create_info) {
2994 skip |=
2995 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
2996 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
2997 "struct in pNext chain.\n",
2998 string_VkBorderColor(pCreateInfo->borderColor));
2999 } else {
3000 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3001 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3002 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3003 !FormatIsSampledFloat(custom_create_info->format)))) {
3004 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3005 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3006 "whose type does not match\n",
3007 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3008 ;
3009 }
3010 }
3011 }
3012
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003013 return skip;
3014}
3015
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003016bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3017 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3018 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003019 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003020 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003021
3022 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3023 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3024 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3025 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003026 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3027 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3028 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3029 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3030 ++descriptor_index) {
3031 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003032 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003033 "vkCreateDescriptorSetLayout: required parameter "
3034 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3035 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003036 }
3037 }
3038 }
3039
3040 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3041 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3042 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003043 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3044 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3045 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3046 "values.",
3047 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003048 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003049
3050 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3051 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3052 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3053 skip |=
3054 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3055 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3056 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3057 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3058 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3059 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003060 }
3061 }
3062 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003063 return skip;
3064}
3065
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003066bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3067 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003068 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003069 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3070 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3071 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003072 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3073 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003074}
3075
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003076bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3077 const VkWriteDescriptorSet *pDescriptorWrites,
3078 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003079 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003080
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003081 if (pDescriptorWrites != NULL) {
3082 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3083 // descriptorCount must be greater than 0
3084 if (pDescriptorWrites[i].descriptorCount == 0) {
3085 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003086 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3087 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003088 }
3089
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003090 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3091 if (validateDstSet) {
3092 // dstSet must be a valid VkDescriptorSet handle
3093 skip |= validate_required_handle(vkCallingFunction,
3094 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3095 pDescriptorWrites[i].dstSet);
3096 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003097
3098 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3099 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3100 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3101 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3102 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3103 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3104 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003105 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3106 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003107 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003108 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3109 "%s(): if pDescriptorWrites[%d].descriptorType is "
3110 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3111 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3112 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3113 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003114 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3115 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003116 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3117 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003118 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3119 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003120 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003121 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3122 ParameterName::IndexVector{i, descriptor_index}),
3123 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003124 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003125 }
3126 }
3127 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3128 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3129 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3130 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3131 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3132 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3133 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003134 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003135 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003136 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3137 "%s(): if pDescriptorWrites[%d].descriptorType is "
3138 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3139 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3140 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3141 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003142 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003143 const auto *robustness2_features =
3144 lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
3145 if (robustness2_features && robustness2_features->nullDescriptor) {
3146 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount;
3147 ++descriptorIndex) {
3148 if (pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer == VK_NULL_HANDLE &&
3149 (pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset != 0 ||
3150 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range != VK_WHOLE_SIZE)) {
3151 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3152 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003153 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Jeff Bolz165818a2020-05-08 11:19:03 -05003154 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset,
3155 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range);
3156 }
3157 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003158 }
3159 }
3160 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3161 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003162 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003163 }
3164
3165 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3166 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003167 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003168 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3169 if (pDescriptorWrites[i].pBufferInfo != NULL) {
3170 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003171 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003172 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3173 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3174 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
3175 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003176 }
3177 }
3178 }
3179 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3180 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003181 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003182 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3183 if (pDescriptorWrites[i].pBufferInfo != NULL) {
3184 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003185 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003186 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3187 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3188 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
3189 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003190 }
3191 }
3192 }
3193 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003194 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3195 // or VkWriteDescriptorSetInlineUniformBlockEX
3196 if (pDescriptorWrites[i].pNext) {
3197 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003198 const auto *pnext_struct =
sourav parmara96ab1a2020-04-25 16:28:23 -07003199 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003200 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003201 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3202 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3203 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3204 "accelerationStructureCount %d member equals descriptorCount %d.",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003205 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
sourav parmara96ab1a2020-04-25 16:28:23 -07003206 pDescriptorWrites[i].descriptorCount);
3207 }
3208 // further checks only if we have right structtype
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003209 if (pnext_struct) {
3210 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003211 skip |= LogError(
3212 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3213 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3214 ".",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003215 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003216 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003217 if (pnext_struct->accelerationStructureCount == 0) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003218 skip |= LogError(
3219 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
3220 "%s(): accelerationStructureCount must be greater than 0 .");
3221 }
3222 }
3223 }
3224 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003225 }
3226 }
3227 return skip;
3228}
3229
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003230bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3231 const VkWriteDescriptorSet *pDescriptorWrites,
3232 uint32_t descriptorCopyCount,
3233 const VkCopyDescriptorSet *pDescriptorCopies) const {
3234 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3235}
3236
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003237bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003238 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003239 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003240 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3241}
3242
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003243bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3244 const VkAllocationCallbacks *pAllocator,
3245 VkRenderPass *pRenderPass) const {
3246 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3247}
3248
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003249bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003250 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003251 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003252 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3253}
3254
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003255bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3256 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003257 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003258 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003259
3260 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3261 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3262 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003263 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3264 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003265 return skip;
3266}
3267
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003268bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003269 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003270 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003271
3272 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3273 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003274 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
3275
Petr Krause7bb9e82019-08-11 21:34:43 +02003276 // Implicit VUs
3277 // validate only sType here; pointer has to be validated in core_validation
3278 const bool kNotRequired = false;
3279 const char *kNoVUID = nullptr;
3280 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
3281 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
3282 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003283
Petr Krause7bb9e82019-08-11 21:34:43 +02003284 if (pInfo) {
3285 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
3286 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
3287 skip |= validate_struct_pnext(
3288 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
3289 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08003290 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
3291 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003292
Petr Krause7bb9e82019-08-11 21:34:43 +02003293 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003294
Petr Krause7bb9e82019-08-11 21:34:43 +02003295 // Explicit VUs
3296 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003297 skip |= LogError(
3298 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02003299 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3300 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003301 }
Petr Krause7bb9e82019-08-11 21:34:43 +02003302
3303 if (physical_device_features.inheritedQueries) {
3304 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003305 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06003306 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02003307 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02003308 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003309 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02003310 }
3311
3312 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02003313 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003314 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003315 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02003316 } else { // !pipelineStatisticsQuery
3317 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
3318 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003319 }
Petr Kraus139757b2019-08-15 17:19:33 +02003320
3321 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
3322 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003323 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02003324 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3325 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003326 skip |= LogError(
3327 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02003328 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3329 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3330 }
3331 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003332 }
3333
3334 return skip;
3335}
3336
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003337bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003338 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003339 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003340
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003341 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003342 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003343 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3344 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3345 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003346 }
3347 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003348 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3349 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3350 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003351 }
3352 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003353 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003354 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003355 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3356 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3357 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3358 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003359 }
3360 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003361
3362 if (pViewports) {
3363 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3364 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003365 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003366 skip |= manual_PreCallValidateViewport(
3367 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003368 }
3369 }
3370
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003371 return skip;
3372}
3373
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003374bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003375 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003376 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003377
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003378 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003379 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003380 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3381 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3382 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003383 }
3384 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003385 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3386 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3387 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003388 }
3389 } else { // multiViewport enabled
3390 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003391 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003392 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3393 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3394 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3395 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003396 }
3397 }
3398
Petr Kraus6260f0a2018-02-27 21:15:55 +01003399 if (pScissors) {
3400 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3401 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003402
Petr Kraus6260f0a2018-02-27 21:15:55 +01003403 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003404 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3405 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3406 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003407 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003408
Petr Kraus6260f0a2018-02-27 21:15:55 +01003409 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003410 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3411 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3412 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003413 }
3414
3415 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3416 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003417 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3418 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3419 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3420 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003421 }
3422
3423 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3424 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003425 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3426 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3427 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3428 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003429 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003430 }
3431 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003432
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003433 return skip;
3434}
3435
Jeff Bolz5c801d12019-10-09 10:38:45 -05003436bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003437 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003438
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003439 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003440 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3441 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003442 }
3443
3444 return skip;
3445}
3446
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003447bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003448 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003449 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003450
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003451 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003452 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003453 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003454 }
3455 return skip;
3456}
3457
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003458bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003459 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003460 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003461 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003462 skip |=
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003463 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003464 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003465 }
3466 return skip;
3467}
3468
sfricke-samsungf692b972020-05-02 08:00:45 -07003469bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3470 VkDeviceSize countBufferOffset, bool khr) const {
3471 bool skip = false;
3472 const char *apiName = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
3473 if (offset & 3) {
3474 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
3475 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3476 }
3477
3478 if (countBufferOffset & 3) {
3479 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
3480 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3481 countBufferOffset);
3482 }
3483 return skip;
3484}
3485
3486bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3487 VkDeviceSize offset, VkBuffer countBuffer,
3488 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3489 uint32_t stride) const {
3490 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3491}
3492
3493bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3494 VkDeviceSize offset, VkBuffer countBuffer,
3495 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3496 uint32_t stride) const {
3497 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3498}
3499
3500bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3501 VkDeviceSize countBufferOffset, bool khr) const {
3502 bool skip = false;
3503 const char *apiName = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
3504 if (offset & 3) {
3505 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
3506 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3507 }
3508
3509 if (countBufferOffset & 3) {
3510 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
3511 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3512 countBufferOffset);
3513 }
3514 return skip;
3515}
3516
3517bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3518 VkDeviceSize offset, VkBuffer countBuffer,
3519 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3520 uint32_t stride) const {
3521 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3522}
3523
3524bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3525 VkDeviceSize offset, VkBuffer countBuffer,
3526 VkDeviceSize countBufferOffset,
3527 uint32_t maxDrawCount, uint32_t stride) const {
3528 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3529}
3530
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003531bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3532 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003533 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003534 bool skip = false;
3535 for (uint32_t rect = 0; rect < rectCount; rect++) {
3536 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003537 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3538 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003539 }
sfricke-samsung10867682020-04-25 02:20:39 -07003540 if (pRects[rect].rect.extent.width == 0) {
3541 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3542 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3543 }
3544 if (pRects[rect].rect.extent.height == 0) {
3545 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3546 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3547 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003548 }
3549 return skip;
3550}
3551
Andrew Fobel3abeb992020-01-20 16:33:22 -05003552bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3553 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3554 VkImageFormatProperties2 *pImageFormatProperties,
3555 const char *apiName) const {
3556 bool skip = false;
3557
3558 if (pImageFormatInfo != nullptr) {
3559 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
3560 if (image_stencil_struct != nullptr) {
3561 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3562 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3563 // No flags other than the legal attachment bits may be set
3564 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3565 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003566 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3567 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3568 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3569 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3570 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003571 }
3572 }
3573 }
3574 }
3575
3576 return skip;
3577}
3578
3579bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3580 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3581 VkImageFormatProperties2 *pImageFormatProperties) const {
3582 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3583 "vkGetPhysicalDeviceImageFormatProperties2");
3584}
3585
3586bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3587 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3588 VkImageFormatProperties2 *pImageFormatProperties) const {
3589 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3590 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3591}
3592
sfricke-samsung3999ef62020-02-09 17:05:59 -08003593bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3594 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3595 bool skip = false;
3596
3597 if (pRegions != nullptr) {
3598 for (uint32_t i = 0; i < regionCount; i++) {
3599 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003600 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3601 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003602 }
3603 }
3604 }
3605 return skip;
3606}
3607
Jeff Leger178b1e52020-10-05 12:22:23 -04003608bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
3609 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
3610 bool skip = false;
3611
3612 if (pCopyBufferInfo->pRegions != nullptr) {
3613 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
3614 if (pCopyBufferInfo->pRegions[i].size == 0) {
3615 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
3616 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
3617 }
3618 }
3619 }
3620 return skip;
3621}
3622
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003623bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003624 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3625 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003626 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003627
3628 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003629 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3630 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3631 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003632 }
3633
3634 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003635 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3636 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3637 "), must be greater than zero and less than or equal to 65536.",
3638 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003639 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003640 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3641 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3642 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003643 }
3644 return skip;
3645}
3646
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003647bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003648 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003649 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003650
3651 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003652 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3653 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3654 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003655 }
3656
3657 if (size != VK_WHOLE_SIZE) {
3658 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003659 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003660 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3661 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003662 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003663 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3664 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003665 }
3666 }
3667 return skip;
3668}
3669
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003670bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003671 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003672 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003673 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003674
3675 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003676 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3677 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3678 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3679 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003680 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3681 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3682 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003683 }
3684
3685 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3686 // queueFamilyIndexCount uint32_t values
3687 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003688 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3689 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3690 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3691 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003692 }
3693 }
3694
Dave Houlton413a6782018-05-22 13:01:54 -06003695 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003696 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003697 }
3698
3699 return skip;
3700}
3701
Jeff Bolz5c801d12019-10-09 10:38:45 -05003702bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003703 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003704
3705 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003706 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3707 if (present_regions) {
3708 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003709 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003710 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3711 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07003712 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003713 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3714 "extension swapchainCount is %i. These values must be equal.",
3715 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003716 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003717 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003718 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3719 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003720 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3721 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3722 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003723 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003724 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003725 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003726 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003727 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003728 }
3729 }
3730
3731 return skip;
3732}
3733
3734#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003735bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3736 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3737 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003738 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003739 bool skip = false;
3740
3741 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003742 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3743 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003744 }
3745
3746 return skip;
3747}
3748#endif // VK_USE_PLATFORM_WIN32_KHR
3749
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003750bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003751 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003752 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003753 bool skip = false;
3754
3755 if (pCreateInfo) {
3756 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003757 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3758 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003759 }
3760
3761 if (pCreateInfo->pPoolSizes) {
3762 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3763 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003764 skip |= LogError(
3765 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003766 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003767 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003768 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3769 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003770 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3771 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3772 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3773 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3774 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003775 }
Petr Krausc8655be2017-09-27 18:56:51 +02003776 }
3777 }
3778 }
3779
3780 return skip;
3781}
3782
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003783bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003784 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003785 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003786
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003787 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003788 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003789 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3790 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3791 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003792 }
3793
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003794 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003795 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003796 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3797 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3798 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003799 }
3800
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003801 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003802 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003803 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3804 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3805 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003806 }
3807
3808 return skip;
3809}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003810
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003811bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003812 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003813 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003814
3815 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003816 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3817 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003818 }
3819 return skip;
3820}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003821
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003822bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3823 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003824 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003825 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003826
3827 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003828 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003829 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003830 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3831 "vkCmdDispatch(): baseGroupX (%" PRIu32
3832 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3833 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003834 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003835 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3836 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3837 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3838 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003839 }
3840
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003841 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003842 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003843 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3844 "vkCmdDispatch(): baseGroupY (%" PRIu32
3845 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3846 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003847 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003848 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3849 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3850 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3851 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003852 }
3853
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003854 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003855 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003856 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3857 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3858 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3859 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003860 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003861 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3862 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3863 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3864 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003865 }
3866
3867 return skip;
3868}
3869
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003870bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3871 VkPipelineBindPoint pipelineBindPoint,
3872 VkPipelineLayout layout, uint32_t set,
3873 uint32_t descriptorWriteCount,
3874 const VkWriteDescriptorSet *pDescriptorWrites) const {
3875 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3876}
3877
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003878bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3879 uint32_t firstExclusiveScissor,
3880 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003881 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003882 bool skip = false;
3883
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003884 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003885 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003886 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003887 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3888 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3889 ") is not 0.",
3890 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003891 }
3892 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003893 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003894 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3895 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3896 ") is not 1.",
3897 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003898 }
3899 } else { // multiViewport enabled
3900 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003901 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003902 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3903 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3904 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3905 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003906 }
3907 }
3908
Jeff Bolz3e71f782018-08-29 23:15:45 -05003909 if (pExclusiveScissors) {
3910 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3911 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3912
3913 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003914 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3915 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3916 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003917 }
3918
3919 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003920 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3921 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3922 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003923 }
3924
3925 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3926 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003927 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3928 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3929 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3930 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003931 }
3932
3933 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3934 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003935 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3936 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3937 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3938 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003939 }
3940 }
3941 }
3942
3943 return skip;
3944}
3945
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003946bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3947 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003948 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003949 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07003950 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3951 if ((sum < 1) || (sum > device_limits.maxViewports)) {
3952 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3953 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3954 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3955 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003956 }
3957
3958 return skip;
3959}
3960
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003961bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3962 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003963 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003964 bool skip = false;
3965
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003966 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003967 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003968 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003969 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3970 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3971 ") is not 0.",
3972 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003973 }
3974 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003975 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003976 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3977 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3978 ") is not 1.",
3979 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003980 }
3981 }
3982
Jeff Bolz9af91c52018-09-01 21:53:57 -05003983 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003984 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003985 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3986 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3987 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3988 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003989 }
3990
3991 return skip;
3992}
3993
Jeff Bolz5c801d12019-10-09 10:38:45 -05003994bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3995 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3996 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003997 bool skip = false;
3998
Dave Houlton142c4cb2018-10-17 15:04:41 -06003999 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004000 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4001 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4002 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004003 }
4004
4005 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004006 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004007 }
4008
4009 return skip;
4010}
4011
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004012bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004013 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004014 bool skip = false;
4015
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004016 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004017 skip |= LogError(
4018 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004019 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4020 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004021 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004022 }
4023
4024 return skip;
4025}
4026
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004027bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4028 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004029 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004030 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004031 static const int condition_multiples = 0b0011;
4032 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004033 skip |= LogError(
4034 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004035 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004036 }
Lockee1c22882019-06-10 16:02:54 -06004037 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004038 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4039 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4040 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4041 stride);
Lockee1c22882019-06-10 16:02:54 -06004042 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004043 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004044 skip |= LogError(
4045 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4046 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004047 }
4048
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004049 return skip;
4050}
4051
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004052bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4053 VkDeviceSize offset, VkBuffer countBuffer,
4054 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004055 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004056 bool skip = false;
4057
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004058 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004059 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4060 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4061 "), is not a multiple of 4.",
4062 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004063 }
4064
4065 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004066 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4067 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4068 "), is not a multiple of 4.",
4069 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004070 }
4071
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004072 return skip;
4073}
4074
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004075bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004076 const VkAllocationCallbacks *pAllocator,
4077 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004078 bool skip = false;
4079
4080 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4081 if (pCreateInfo != nullptr) {
4082 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4083 // VkQueryPipelineStatisticFlagBits values
4084 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4085 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004086 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4087 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4088 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4089 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004090 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004091 if (pCreateInfo->queryCount == 0) {
4092 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4093 "vkCreateQueryPool(): queryCount must be greater than zero.");
4094 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004095 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004096 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004097}
4098
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004099bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4100 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004101 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004102 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4103 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004104}
4105
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004106void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004107 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4108 VkResult result) {
4109 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004110 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004111}
4112
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004113void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004114 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4115 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004116 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004117 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004118 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004119}
4120
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004121void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4122 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004123 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004124 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004125 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004126}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004127
4128bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004129 const VkAllocationCallbacks *pAllocator,
4130 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004131 bool skip = false;
4132
4133 if (pAllocateInfo) {
4134 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
4135 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004136 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4137 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004138 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004139
4140 VkMemoryAllocateFlags flags = 0;
4141 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
4142 if (flags_info) {
4143 flags = flags_info->flags;
4144 }
4145
4146 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
4147 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
4148 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004149 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4150 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
4151 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004152 }
4153
4154#ifdef VK_USE_PLATFORM_WIN32_KHR
4155 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
4156#endif
4157 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4158 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
4159#ifdef VK_USE_PLATFORM_ANDROID_KHR
4160 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
4161#endif
4162
4163 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004164 skip |= LogError(
4165 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004166 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4167 }
4168 if (
4169#ifdef VK_USE_PLATFORM_WIN32_KHR
4170 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4171#endif
4172 (import_memory_fd && import_memory_fd->handleType) ||
4173#ifdef VK_USE_PLATFORM_ANDROID_KHR
4174 (import_memory_ahb && import_memory_ahb->buffer) ||
4175#endif
4176 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004177 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4178 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004179 }
4180 }
4181
4182 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004183 VkBool32 capture_replay = false;
4184 VkBool32 buffer_device_address = false;
4185 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
4186 if (vulkan_12_features) {
4187 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4188 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4189 } else {
4190 const auto *bda_features =
4191 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
4192 if (bda_features) {
4193 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4194 buffer_device_address = bda_features->bufferDeviceAddress;
4195 }
4196 }
4197 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004198 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
4199 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
4200 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004201 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004202 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004203 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
4204 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004205 }
4206 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004207 }
4208 return skip;
4209}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004210
Jason Macnak192fa0e2019-07-26 15:07:16 -07004211bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004212 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004213 bool skip = false;
4214
4215 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4216 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4217 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004218 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004219 } else {
4220 uint32_t vertex_component_size = 0;
4221 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4222 vertex_component_size = 4;
4223 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4224 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4225 vertex_component_size = 2;
4226 }
4227 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004228 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004229 }
4230 }
4231
4232 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4233 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004234 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004235 } else {
4236 uint32_t index_element_size = 0;
4237 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4238 index_element_size = 4;
4239 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4240 index_element_size = 2;
4241 }
4242 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004243 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004244 }
4245 }
4246 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4247 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004248 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004249 }
4250 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004251 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004252 }
4253 }
4254
4255 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004256 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004257 }
4258
4259 return skip;
4260}
4261
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004262bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4263 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004264 bool skip = false;
4265
4266 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004267 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004268 }
4269 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004270 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004271 }
4272
4273 return skip;
4274}
4275
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004276bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4277 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004278 bool skip = false;
4279 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004280 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004281 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004282 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004283 }
4284 return skip;
4285}
4286
4287bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004288 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004289 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004290 bool skip = false;
4291 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004292 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4293 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4294 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004295 }
4296 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004297 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4298 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4299 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004300 }
4301 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4302 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004303 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4304 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4305 "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 -07004306 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004307 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004308 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004309 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4310 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004311 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4312 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004313 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004314 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004315 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4316 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4317 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004318 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004319 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004320 uint64_t total_triangle_count = 0;
4321 for (uint32_t i = 0; i < info.geometryCount; i++) {
4322 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004323
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004324 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004325
Jason Macnak5c954952019-07-09 15:46:12 -07004326 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4327 continue;
4328 }
4329 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4330 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004331 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004332 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4333 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4334 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004335 }
4336 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004337 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4338 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4339 for (uint32_t i = 1; i < info.geometryCount; i++) {
4340 const VkGeometryNV &geometry = info.pGeometries[i];
4341 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004342 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004343 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4344 "info.pGeometries[0].geometryType.",
4345 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004346 }
4347 }
4348 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004349 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4350 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4351 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4352 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4353 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4354 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4355 }
4356 }
4357 skip |=
4358 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004359 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004360 return skip;
4361}
4362
Ricardo Garciaa4935972019-02-21 17:43:18 +01004363bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4364 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004365 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004366 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004367 if (pCreateInfo) {
4368 if ((pCreateInfo->compactedSize != 0) &&
4369 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004370 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4371 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4372 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4373 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004374 }
Jason Macnak5c954952019-07-09 15:46:12 -07004375
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004376 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004377 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004378 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004379 return skip;
4380}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004381
Jeff Bolz5c801d12019-10-09 10:38:45 -05004382bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4383 const VkAccelerationStructureInfoNV *pInfo,
4384 VkBuffer instanceData, VkDeviceSize instanceOffset,
4385 VkBool32 update, VkAccelerationStructureNV dst,
4386 VkAccelerationStructureNV src, VkBuffer scratch,
4387 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004388 bool skip = false;
4389
4390 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004391 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004392 }
4393
4394 return skip;
4395}
4396
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004397bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4398 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4399 VkAccelerationStructureKHR *pAccelerationStructure) const {
4400 bool skip = false;
4401
4402 if (pCreateInfo) {
4403 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
4404 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4405 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4406 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
4407 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
4408 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4409 i);
4410 }
4411 }
4412
4413 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4414 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4415 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
4416 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
4417 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4418 i);
4419 }
4420 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004421 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
4422 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
4423 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
4424 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
4425 skip |= LogError(
4426 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
4427 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
4428 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
4429 }
4430 }
4431 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
4432 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
4433 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
4434 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4435 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
4436 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
4437 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
4438 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
4439 }
4440 }
4441 }
4442
4443 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
4444 pCreateInfo->maxGeometryCount != 1) {
4445 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
4446 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4447 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004448 }
sourav parmard1521802020-06-07 21:49:02 -07004449 // or VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490
4450 if (pCreateInfo->compactedSize == 0 && pCreateInfo->maxGeometryCount == 0) {
4451 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-02993",
4452 "VkAccelerationStructureCreateInfoKHR: If compactedSize is 0 then maxGeometryCount must not be 0.");
4453 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004454
4455 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
4456 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
4457 skip |= LogError(
4458 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
4459 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
4460 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
4461 }
4462
4463 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
4464 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
4465 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
4466 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
4467 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
4468 }
4469
4470 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
4471 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
4472 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
4473 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
4474 if (geometry_type != first_geometry_type) {
4475 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
4476 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
4477 "pGeometryInfos[0].geometryType.",
4478 i);
4479 }
4480 }
4481 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004482 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
4483 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
4484 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
4485 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
4486 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
4487 "maxGeometryCount %d.",
4488 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
4489 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004490 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004491 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4492 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
4493 if (pCreateInfo->deviceAddress != 0) {
4494 skip |=
4495 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
4496 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
4497 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
4498 }
4499 }
sourav parmar83c31b12020-05-06 12:30:54 -07004500 if (!raytracing_features || !(raytracing_features->rayQuery == VK_TRUE || raytracing_features->rayTracing == VK_TRUE)) {
4501 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-rayTracing-03487",
4502 "vkCreateAccelerationStructureKHR: The rayTracing or rayQuery feature must be enabled.");
4503 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004504 return skip;
4505}
4506
Jason Macnak5c954952019-07-09 15:46:12 -07004507bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4508 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004509 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004510 bool skip = false;
4511 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004512 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4513 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004514 }
4515 return skip;
4516}
4517
Peter Chen85366392019-05-14 15:20:11 -04004518bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4519 uint32_t createInfoCount,
4520 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4521 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004522 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004523 bool skip = false;
4524
4525 for (uint32_t i = 0; i < createInfoCount; i++) {
4526 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4527 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004528 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004529 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4530 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4531 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4532 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004533 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004534
4535 const auto *pipeline_cache_contol_features =
4536 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4537 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4538 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4539 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4540 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4541 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4542 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4543 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4544 }
4545 }
4546
sourav parmarf4a78252020-04-10 13:04:21 -07004547 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4548 skip |=
4549 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4550 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4551 }
4552 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4553 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4554 skip |=
4555 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4556 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4557 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4558 }
4559 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4560 if (pCreateInfos[i].basePipelineIndex != -1) {
4561 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4562 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4563 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4564 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4565 "and pCreateInfos->basePipelineIndex is not -1.");
4566 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004567 if (pCreateInfos[i].basePipelineIndex > (int32_t)(i)) {
4568 skip |=
4569 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
4570 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
4571 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
4572 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
4573 "that element.");
4574 }
sourav parmarf4a78252020-04-10 13:04:21 -07004575 }
4576 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004577 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004578 skip |=
4579 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4580 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4581 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4582 "commands pCreateInfos parameter.");
4583 }
4584 } else {
4585 if (pCreateInfos[i].basePipelineIndex != -1) {
4586 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4587 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4588 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4589 }
4590 }
4591 }
4592 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4593 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4594 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4595 }
4596 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4597 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4598 "vkCreateRayTracingPipelinesNV: flags must not include "
4599 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4600 }
4601 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4602 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4603 "vkCreateRayTracingPipelinesNV: flags must not include "
4604 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4605 }
4606 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4607 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4608 "vkCreateRayTracingPipelinesNV: flags must not include "
4609 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4610 }
4611 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4612 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4613 "vkCreateRayTracingPipelinesNV: flags must not include "
4614 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4615 }
4616 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4617 skip |= LogError(
4618 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4619 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4620 }
4621 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4622 skip |= LogError(
4623 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4624 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4625 }
Peter Chen85366392019-05-14 15:20:11 -04004626 }
4627
4628 return skip;
4629}
4630
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004631bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4632 uint32_t createInfoCount,
4633 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4634 const VkAllocationCallbacks *pAllocator,
4635 VkPipeline *pPipelines) const {
4636 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004637 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4638 if (!raytracing_features || raytracing_features->rayTracing == VK_FALSE) {
4639 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracing-03455",
4640 "vkCreateRayTracingPipelinesKHR(): The rayTracing feature must be enabled.");
4641 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004642 for (uint32_t i = 0; i < createInfoCount; i++) {
4643 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4644 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4645 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4646 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4647 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4648 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4649 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4650 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004651 const auto *pipeline_cache_contol_features =
4652 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4653 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4654 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4655 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4656 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4657 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4658 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4659 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4660 }
4661 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004662 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4663 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4664 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4665 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4666 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4667 }
4668 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4669 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4670 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4671 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4672 }
4673 }
4674
sourav parmarf4a78252020-04-10 13:04:21 -07004675 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4676 skip |=
4677 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4678 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4679 }
4680 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4681 if (pCreateInfos[i].pLibraryInterface == NULL)
4682 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4683 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4684 }
4685 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4686 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4687 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4688 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4689 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4690 skip |= LogError(
4691 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4692 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4693 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4694 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4695 "must not be VK_SHADER_UNUSED_KHR");
4696 }
4697 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4698 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4699 skip |= LogError(
4700 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4701 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4702 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4703 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4704 "element must not be VK_SHADER_UNUSED_KHR");
4705 }
4706 }
4707 }
4708 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4709 if (pCreateInfos[i].basePipelineIndex != -1) {
4710 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4711 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4712 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4713 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4714 "and pCreateInfos->basePipelineIndex is not -1.");
4715 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004716 if (pCreateInfos[i].basePipelineIndex > (int32_t)i) {
4717 skip |=
4718 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
4719 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
4720 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
4721 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
4722 "element.");
4723 }
sourav parmarf4a78252020-04-10 13:04:21 -07004724 }
4725 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004726 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004727 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4728 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4729 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4730 "commands pCreateInfos parameter %d.",
4731 pCreateInfos[i].basePipelineIndex, createInfoCount);
4732 }
4733 } else {
4734 if (pCreateInfos[i].basePipelineIndex != -1) {
4735 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4736 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4737 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4738 }
4739 }
4740 }
4741 if (pCreateInfos[i].libraries.libraryCount == 0) {
4742 if (pCreateInfos[i].stageCount == 0) {
4743 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4744 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4745 }
4746 if (pCreateInfos[i].groupCount == 0) {
4747 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4748 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4749 }
4750 } else {
4751 if (pCreateInfos[i].pLibraryInterface == NULL) {
4752 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4753 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4754 }
4755 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004756 }
4757
4758 return skip;
4759}
4760
Mike Schuchardt21638df2019-03-16 10:52:02 -07004761#ifdef VK_USE_PLATFORM_WIN32_KHR
4762bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4763 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004764 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004765 bool skip = false;
4766 if (!device_extensions.vk_khr_swapchain)
4767 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4768 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4769 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4770 if (!device_extensions.vk_khr_surface)
4771 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4772 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4773 skip |=
4774 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4775 if (!device_extensions.vk_ext_full_screen_exclusive)
4776 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4777 skip |= validate_struct_type(
4778 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4779 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4780 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4781 if (pSurfaceInfo != NULL) {
4782 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4783 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4784 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4785
4786 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4787 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4788 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4789 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004790 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4791 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004792
4793 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4794 }
4795 return skip;
4796}
4797#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004798
4799bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4800 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004801 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004802 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4803 bool skip = false;
4804 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4805 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4806 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4807 }
4808 return skip;
4809}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004810
4811bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004812 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004813 bool skip = false;
4814
4815 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004816 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4817 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004818 }
4819
4820 return skip;
4821}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004822
4823bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004824 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004825 bool skip = false;
4826
4827 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004828 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4829 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004830 }
4831
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004832 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06004833 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004834 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4835 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004836 }
4837
4838 return skip;
4839}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004840
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004841bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4842 uint32_t bindingCount, const VkBuffer *pBuffers,
4843 const VkDeviceSize *pOffsets) const {
4844 bool skip = false;
4845 if (firstBinding > device_limits.maxVertexInputBindings) {
4846 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4847 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4848 device_limits.maxVertexInputBindings);
4849 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4850 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4851 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4852 "maxVertexInputBindings (%u)",
4853 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4854 }
4855
Jeff Bolz165818a2020-05-08 11:19:03 -05004856 for (uint32_t i = 0; i < bindingCount; ++i) {
4857 if (pBuffers[i] == VK_NULL_HANDLE) {
4858 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
4859 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
4860 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
4861 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
4862 } else {
4863 if (pOffsets[i] != 0) {
4864 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
4865 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
4866 }
4867 }
4868 }
4869 }
4870
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004871 return skip;
4872}
4873
Mark Lobodzinski84988402019-09-11 15:27:30 -06004874bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004875 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004876 bool skip = false;
4877 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004878 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4879 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004880 }
4881 return skip;
4882}
4883
4884bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004885 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004886 bool skip = false;
4887 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004888 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4889 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004890 }
4891 return skip;
4892}
Petr Kraus3d720392019-11-13 02:52:39 +01004893
4894bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4895 VkSemaphore semaphore, VkFence fence,
4896 uint32_t *pImageIndex) const {
4897 bool skip = false;
4898
4899 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004900 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4901 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004902 }
4903
4904 return skip;
4905}
4906
4907bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4908 uint32_t *pImageIndex) const {
4909 bool skip = false;
4910
4911 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004912 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4913 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004914 }
4915
4916 return skip;
4917}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004918
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06004919bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
4920 uint32_t firstBinding, uint32_t bindingCount,
4921 const VkBuffer *pBuffers,
4922 const VkDeviceSize *pOffsets,
4923 const VkDeviceSize *pSizes) const {
4924 bool skip = false;
4925
4926 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
4927 for (uint32_t i = 0; i < bindingCount; ++i) {
4928 if (pOffsets[i] & 3) {
4929 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
4930 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
4931 }
4932 }
4933
4934 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4935 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
4936 "%s: The firstBinding(%" PRIu32
4937 ") index is greater than or equal to "
4938 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4939 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4940 }
4941
4942 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4943 skip |=
4944 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
4945 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
4946 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4947 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4948 }
4949
4950 for (uint32_t i = 0; i < bindingCount; ++i) {
4951 // pSizes is optional and may be nullptr.
4952 if (pSizes != nullptr) {
4953 if (pSizes[i] != VK_WHOLE_SIZE &&
4954 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
4955 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
4956 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
4957 ") is not VK_WHOLE_SIZE and is greater than "
4958 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
4959 cmd_name, i, pSizes[i]);
4960 }
4961 }
4962 }
4963
4964 return skip;
4965}
4966
4967bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
4968 uint32_t firstCounterBuffer,
4969 uint32_t counterBufferCount,
4970 const VkBuffer *pCounterBuffers,
4971 const VkDeviceSize *pCounterBufferOffsets) const {
4972 bool skip = false;
4973
4974 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
4975 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4976 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
4977 "%s: The firstCounterBuffer(%" PRIu32
4978 ") index is greater than or equal to "
4979 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4980 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4981 }
4982
4983 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4984 skip |=
4985 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
4986 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
4987 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4988 cmd_name, firstCounterBuffer, counterBufferCount,
4989 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4990 }
4991
4992 return skip;
4993}
4994
4995bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
4996 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
4997 const VkBuffer *pCounterBuffers,
4998 const VkDeviceSize *pCounterBufferOffsets) const {
4999 bool skip = false;
5000
5001 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5002 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5003 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5004 "%s: The firstCounterBuffer(%" PRIu32
5005 ") index is greater than or equal to "
5006 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5007 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5008 }
5009
5010 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5011 skip |=
5012 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5013 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5014 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5015 cmd_name, firstCounterBuffer, counterBufferCount,
5016 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5017 }
5018
5019 return skip;
5020}
5021
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005022bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5023 uint32_t firstInstance, VkBuffer counterBuffer,
5024 VkDeviceSize counterBufferOffset,
5025 uint32_t counterOffset, uint32_t vertexStride) const {
5026 bool skip = false;
5027
5028 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005029 skip |= LogError(
5030 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005031 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5032 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5033 }
5034
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005035 if ((counterOffset % 4) != 0) {
5036 // TODO - Update when header are updated
5037 skip |= LogError(commandBuffer, "UNASSIGNED-vkCmdDrawIndirectByteCountEXT-offset",
5038 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu64 ") must be a multiple of 4.", counterOffset);
5039 }
5040
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005041 return skip;
5042}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005043
5044bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5045 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5046 const VkAllocationCallbacks *pAllocator,
5047 VkSamplerYcbcrConversion *pYcbcrConversion,
5048 const char *apiName) const {
5049 bool skip = false;
5050
5051 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07005052 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005053 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005054 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
5055 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5056 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005057 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005058 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005059 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005060
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005061#ifdef VK_USE_PLATFORM_ANDROID_KHR
5062 const VkExternalFormatANDROID *pExternalFormatANDROID = lvl_find_in_chain<VkExternalFormatANDROID>(pCreateInfo);
5063 const bool isExternalFormat = pExternalFormatANDROID != nullptr && pExternalFormatANDROID->externalFormat != 0;
5064#else
5065 const bool isExternalFormat = false;
5066#endif
5067
sfricke-samsung1a72f942020-07-25 12:09:18 -07005068 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005069
5070 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
5071 if (!isExternalFormat) {
5072 const VkComponentMapping components = pCreateInfo->components;
5073 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5074 if (FormatIsXChromaSubsampled(format) == true) {
5075 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5076 skip |=
5077 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005078 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5079 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005080 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005081 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005082
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005083 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5084 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5085 skip |= LogError(
5086 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5087 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5088 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5089 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5090 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005091
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005092 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5093 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5094 skip |=
5095 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005096 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5097 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005098 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005099 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005100
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005101 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5102 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5103 skip |=
5104 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005105 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5106 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005107 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005108 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005109
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005110 // If one is identity, both need to be
5111 const bool rIdentity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5112 const bool bIdentity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5113 if ((rIdentity != bIdentity) && ((rIdentity == true) || (bIdentity == true))) {
5114 skip |=
5115 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005116 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5117 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005118 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5119 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005120 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005121 }
5122
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005123 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5124 // Checks same VU multiple ways in order to give a more useful error message
5125 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5126 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5127 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5128 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5129 skip |= LogError(
5130 device, vuid,
5131 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5132 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5133 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5134 string_VkComponentSwizzle(components.b));
5135 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005136
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005137 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5138 // 4 channel format = no issue
5139 // 3 = no [a]
5140 // 2 = no [b,a]
5141 // 1 = no [g,b,a]
5142 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5143 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5144
5145 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5146 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5147 skip |= LogError(device, vuid,
5148 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5149 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5150 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5151 string_VkComponentSwizzle(components.b));
5152 } else if ((channels < 3) &&
5153 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5154 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5155 skip |= LogError(device, vuid,
5156 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5157 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5158 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5159 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5160 string_VkComponentSwizzle(components.b));
5161 } else if ((channels < 2) &&
5162 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5163 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5164 skip |= LogError(device, vuid,
5165 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5166 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5167 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5168 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5169 string_VkComponentSwizzle(components.b));
5170 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005171 }
5172 }
5173
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005174 return skip;
5175}
5176
5177bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5178 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5179 const VkAllocationCallbacks *pAllocator,
5180 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5181 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5182 "vkCreateSamplerYcbcrConversion");
5183}
5184
5185bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5186 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5187 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5188 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5189 "vkCreateSamplerYcbcrConversionKHR");
5190}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005191
5192bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5193 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5194 bool skip = false;
5195 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5196 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5197
5198 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005199 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5200 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5201 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5202 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5203 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005204 }
5205 return skip;
5206}
sourav parmara96ab1a2020-04-25 16:28:23 -07005207
5208bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
5209 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5210 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005211 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5212 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5213 skip |=
5214 LogError(device, "", "VUID-vkCopyAccelerationStructureToMemoryKHR-rayTracingHostAccelerationStructureCommands-03447",
5215 "vkCopyAccelerationStructureToMemoryKHR: the "
5216 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
5217 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005218 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5219 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5220 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5221 }
5222 return skip;
5223}
5224
5225bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5226 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5227 bool skip = false;
5228 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5229 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5230 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5231 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5232 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005233 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5234 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005235 skip |= LogError(
5236 commandBuffer, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pNext-03560",
5237 "vkCmdCopyAccelerationStructureToMemoryKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
5238 "pNext chain of the VkCopyAccelerationStructureToMemoryInfoKHR structure.");
5239 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005240 return skip;
5241}
5242
5243bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5244 const char *api_name) const {
5245 bool skip = false;
5246 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5247 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5248 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5249 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5250 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5251 api_name);
5252 }
5253 return skip;
5254}
5255
5256bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
5257 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5258 bool skip = false;
5259 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
sourav parmar83c31b12020-05-06 12:30:54 -07005260 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5261 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5262 skip |= LogError(
5263 device, "VUID-vkCopyAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03441",
5264 "vkCopyAccelerationStructureKHR(): the "
5265 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled .");
5266 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005267 return skip;
5268}
5269
5270bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5271 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5272 bool skip = false;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005273 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5274 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005275 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureKHR-pNext-03557",
5276 "vkCmdCopyAccelerationStructureKHR(): The VkDeferredOperationInfoKHR structure must not be included in "
5277 "the pNext chain of the VkCopyAccelerationStructureInfoKHR structure.");
5278 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005279 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5280 return skip;
5281}
5282
5283bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005284 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005285 bool skip = false;
5286 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07005287 skip |= LogError(device,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005288 is_cmd ? "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-mode-03413"
Shannon McPhersonafe55122020-05-25 16:20:19 -06005289 : "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005290 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5291 }
5292 return skip;
5293}
5294
5295bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
5296 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5297 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005298 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
5299 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5300 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5301 skip |=
5302 LogError(device, "VUID-vkCopyMemoryToAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03444",
5303 "vkCopyMemoryToAccelerationStructureKHR() :the "
5304 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
5305 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005306 return skip;
5307}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005308
sourav parmara96ab1a2020-04-25 16:28:23 -07005309bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5310 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5311 bool skip = false;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005312 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5313 if (pnext_struct) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005314 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pNext-03564",
5315 "vkCmdCopyMemoryToAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must"
5316 "not be included in the pNext chain of the VkCopyMemoryToAccelerationStructureInfoKHR structure.");
5317 }
sourav parmar83c31b12020-05-06 12:30:54 -07005318 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
5319 return skip;
5320}
5321bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5322 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5323 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5324 bool skip = false;
5325 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5326 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5327 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5328 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5329 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5330 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5331 }
5332 return skip;
5333}
5334bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5335 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5336 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5337 bool skip = false;
5338 if (dataSize < accelerationStructureCount * stride) {
5339 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5340 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5341 "accelerationStructureCount (%d) *stride(%zu).",
5342 dataSize, accelerationStructureCount, stride);
5343 }
5344 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5345 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5346 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5347 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5348 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5349 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5350 }
5351 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5352 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5353 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5354 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5355 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5356 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5357 stride);
5358 }
5359 }
5360 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5361 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5362 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5363 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5364 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5365 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5366 stride);
5367 }
5368 }
5369 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5370 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5371 skip |=
5372 LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-rayTracingHostAccelerationStructureCommands-03454",
5373 "vkWriteAccelerationStructuresPropertiesKHR: the "
5374 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5375 "feature must be enabled ");
5376 }
5377 return skip;
5378}
5379bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5380 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5381 bool skip = false;
5382 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5383 if (!raytracing_features || raytracing_features->rayTracingShaderGroupHandleCaptureReplay == VK_FALSE) {
5384 skip |= LogError(device,
5385 "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingShaderGroupHandleCaptureReplay-03485",
5386 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR: "
5387 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingShaderGroupHandleCaptureReplay"
5388 "must be enabled to call this function.");
5389 }
5390 return skip;
5391}
5392
5393bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
5394 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5395 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5396 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5397 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5398 uint32_t width, uint32_t height, uint32_t depth) const {
5399 bool skip = false;
5400 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5401 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04038",
5402 "vkCmdTraceRaysKHR: The offset member of pCallableShaderBindingTable"
5403 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5404 }
5405 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5406 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04040",
5407 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5408 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5409 }
5410 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5411 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5412 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
5413 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5414 }
5415 // hitShader
5416 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5417 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04032",
5418 "vkCmdTraceRaysKHR: The offset member of pHitShaderBindingTable must be a multiple"
5419 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5420 }
5421 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5422 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04034",
5423 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple"
5424 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5425 }
5426 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5427 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
5428 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be"
5429 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5430 }
5431
5432 // missShader
5433 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5434 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04026",
5435 "vkCmdTraceRaysKHR: The offset member of pMissShaderBindingTable must be a multiple"
5436 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5437 }
5438 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5439 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04028",
5440 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple"
5441 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5442 }
5443 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5444 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5445 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
5446 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5447 }
5448
5449 // raygenShader
5450 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5451 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-04021",
5452 "vkCmdTraceRaysKHR: pRayGenShaderBindingTable->offset must be a multiple"
5453 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5454 }
5455 return skip;
5456}
5457
5458bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer,
5459 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5460 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5461 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5462 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5463 VkBuffer buffer, VkDeviceSize offset) const {
5464 bool skip = false;
5465 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5466 if (!raytracing_features || raytracing_features->rayTracingIndirectTraceRays == VK_FALSE) {
5467 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingIndirectTraceRays-03518",
5468 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectTraceRays "
5469 "feature must be enabled.");
5470 }
5471 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5472 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04038",
5473 "vkCmdTraceRaysIndirectKHR: The offset member of pCallableShaderBindingTable"
5474 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5475 }
5476 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5477 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04040",
5478 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5479 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5480 }
5481 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5482 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
5483 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be"
5484 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5485 }
5486 // hitShader
5487 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5488 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04032",
5489 "vkCmdTraceRaysIndirectKHR: The offset member of pHitShaderBindingTable must be a multiple"
5490 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5491 }
5492 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5493 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04034",
5494 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple"
5495 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5496 }
5497 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5498 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
5499 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be"
5500 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5501 }
5502
5503 // missShader
5504 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5505 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04026",
5506 "vkCmdTraceRaysIndirectKHR: The offset member of pMissShaderBindingTable must be a multiple"
5507 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5508 }
5509 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5510 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04028",
5511 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be a multiple"
5512 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5513 }
5514 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5515 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
5516 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be"
5517 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5518 }
5519
5520 // raygenShader
5521 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5522 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-04021",
5523 "vkCmdTraceRaysIndirectKHR: pRayGenShaderBindingTable->offset must be a multiple"
5524 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5525 }
5526 return skip;
5527}
5528bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5529 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5530 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5531 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5532 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5533 uint32_t width, uint32_t height, uint32_t depth) const {
5534 bool skip = false;
5535 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5536 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5537 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5538 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5539 }
5540 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5541 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5542 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5543 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5544 }
5545 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5546 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5547 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5548 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5549 }
5550
5551 // hitShader
5552 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5553 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5554 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5555 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5556 }
5557 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5558 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5559 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5560 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5561 }
5562 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5563 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5564 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5565 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5566 }
5567
5568 // missShader
5569 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5570 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5571 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5572 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5573 }
5574 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5575 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5576 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5577 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5578 }
5579 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5580 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5581 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5582 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5583 }
5584
5585 // raygenShader
5586 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5587 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5588 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07005589 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5590 }
5591 if (width > device_limits.maxComputeWorkGroupCount[0]) {
5592 skip |=
5593 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
5594 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
5595 }
5596 if (height > device_limits.maxComputeWorkGroupCount[1]) {
5597 skip |=
5598 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
5599 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
5600 }
5601 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
5602 skip |=
5603 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
5604 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07005605 }
5606 return skip;
5607}
5608
5609bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureIndirectKHR(
5610 VkCommandBuffer commandBuffer, const VkAccelerationStructureBuildGeometryInfoKHR *pInfo, VkBuffer indirectBuffer,
5611 VkDeviceSize indirectOffset, uint32_t indirectStride) const {
5612 bool skip = false;
5613 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5614 if (!raytracing_features || raytracing_features->rayTracingIndirectAccelerationStructureBuild == VK_FALSE) {
5615 skip |= LogError(
5616 device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-rayTracingIndirectAccelerationStructureBuild-03535",
5617 "vkCmdBuildAccelerationStructureIndirectKHR: The "
5618 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectAccelerationStructureBuild feature must be enabled.");
5619 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005620 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5621 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005622 skip |=
5623 LogError(device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-pNext-03536",
5624 "vkCmdBuildAccelerationStructureIndirectKHR: The VkDeferredOperationInfoKHR structure must not be included in "
5625 "the pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5626 }
5627 return false;
5628}
5629
5630bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
5631 VkDevice device, const VkAccelerationStructureVersionKHR *version) const {
5632 bool skip = false;
5633 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5634 if (!raytracing_features || !(raytracing_features->rayQuery || raytracing_features->rayTracing)) {
5635 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracing-03565",
5636 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5637 }
5638 return skip;
5639}
5640
5641bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructureKHR(
5642 VkDevice device, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5643 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5644 bool skip = false;
5645 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5646 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005647 skip |= LogError(device, "VUID-vkBuildAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03439",
5648 "vkBuildAccelerationStructureKHR: The "
5649 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5650 "feature must be enabled .");
sourav parmar83c31b12020-05-06 12:30:54 -07005651 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005652 return skip;
5653}
sourav parmara24fb7b2020-05-26 10:50:04 -07005654bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureKHR(
5655 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5656 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5657 bool skip = false;
5658 for (uint32_t i = 0; i < infoCount; ++i) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005659 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfos->pNext);
5660 if (pnext_struct) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005661 skip |=
5662 LogError(commandBuffer, "VUID-vkCmdBuildAccelerationStructureKHR-pNext-03532",
5663 "vkCmdBuildAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
5664 "pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5665 }
5666 }
5667 return skip;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005668}
Piers Daniell39842ee2020-07-10 16:42:33 -06005669
5670bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
5671 const VkViewport *pViewports) const {
5672 bool skip = false;
5673
5674 if (!physical_device_features.multiViewport) {
5675 if (viewportCount != 1) {
5676 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
5677 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5678 ") is not 1.",
5679 viewportCount);
5680 }
5681 } else { // multiViewport enabled
5682 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
5683 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
5684 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
5685 ") must "
5686 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5687 viewportCount, device_limits.maxViewports);
5688 }
5689 }
5690
5691 if (pViewports) {
5692 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
5693 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
5694 const char *fn_name = "vkCmdSetViewportWithCountEXT";
5695 skip |= manual_PreCallValidateViewport(
5696 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
5697 }
5698 }
5699
5700 return skip;
5701}
5702
5703bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
5704 const VkRect2D *pScissors) const {
5705 bool skip = false;
5706
5707 if (!physical_device_features.multiViewport) {
5708 if (scissorCount != 1) {
5709 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
5710 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5711 ") must "
5712 "be 1 when the multiViewport feature is disabled.",
5713 scissorCount);
5714 }
5715 } else { // multiViewport enabled
5716 if (scissorCount == 0) {
5717 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5718 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5719 ") must "
5720 "be great than zero.",
5721 scissorCount);
5722 } else if (scissorCount > device_limits.maxViewports) {
5723 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5724 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5725 ") must "
5726 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5727 scissorCount, device_limits.maxViewports);
5728 }
5729 }
5730
5731 if (pScissors) {
5732 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
5733 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
5734
5735 if (scissor.offset.x < 0) {
5736 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5737 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
5738 scissor.offset.x);
5739 }
5740
5741 if (scissor.offset.y < 0) {
5742 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5743 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
5744 scissor.offset.y);
5745 }
5746
5747 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5748 if (x_sum > INT32_MAX) {
5749 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
5750 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5751 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5752 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
5753 }
5754
5755 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5756 if (y_sum > INT32_MAX) {
5757 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
5758 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5759 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5760 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
5761 }
5762 }
5763 }
5764
5765 return skip;
5766}
5767
5768bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5769 uint32_t bindingCount, const VkBuffer *pBuffers,
5770 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
5771 const VkDeviceSize *pStrides) const {
5772 bool skip = false;
5773 if (firstBinding >= device_limits.maxVertexInputBindings) {
5774 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
5775 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
5776 firstBinding, device_limits.maxVertexInputBindings);
5777 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5778 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
5779 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5780 "maxVertexInputBindings (%u)",
5781 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5782 }
5783
5784 for (uint32_t i = 0; i < bindingCount; ++i) {
5785 if (pBuffers[i] == VK_NULL_HANDLE) {
5786 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
5787 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5788 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
5789 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5790 } else {
5791 if (pOffsets[i] != 0) {
5792 skip |=
5793 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
5794 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5795 }
5796 }
5797 }
5798 if (pStrides) {
5799 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
5800 skip |=
5801 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
5802 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%u) must be less than maxVertexInputBindingStride (%u)", i,
5803 pStrides[i], device_limits.maxVertexInputBindingStride);
5804 }
5805 }
5806 }
5807
5808 return skip;
5809}