blob: e2210e3fe0689295f79e20db7fac6f69ad7680b7 [file] [log] [blame]
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07001/* Copyright (c) 2015-2021 The Khronos Group Inc.
2 * Copyright (c) 2015-2021 Valve Corporation
3 * Copyright (c) 2015-2021 LunarG, Inc.
4 * Copyright (C) 2015-2021 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
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070028static const int kMaxParamCheckerStringLength = 256;
Mark Lobodzinskid4950072017-08-01 13:02:20 -060029
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 Lobodzinski21b91fe2020-12-03 15:44:24 -070036read_lock_guard_t StatelessValidation::read_lock() { return read_lock_guard_t(validation_object_mutex, std::defer_lock); }
37write_lock_guard_t StatelessValidation::write_lock() { return write_lock_guard_t(validation_object_mutex, std::defer_lock); }
38
Jeremy Gebbencbf22862021-03-03 12:01:22 -070039static layer_data::unordered_map<VkCommandBuffer, VkCommandPool> secondary_cb_map{};
Tony-LunarG3c287f62020-12-17 12:39:49 -070040static ReadWriteLock secondary_cb_map_mutex;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -070041static read_lock_guard_t cb_read_lock() { return read_lock_guard_t(secondary_cb_map_mutex); }
42static write_lock_guard_t cb_write_lock() { return write_lock_guard_t(secondary_cb_map_mutex); }
Tony-LunarG3c287f62020-12-17 12:39:49 -070043
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070044bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050045 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060046 bool skip = false;
47
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070048 VkStringErrorFlags result = vk_string_validate(kMaxParamCheckerStringLength, validateString);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060049
50 if (result == VK_STRING_ERROR_NONE) {
51 return skip;
52 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070053 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070054 kMaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060055 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070056 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
57 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060058 }
59 return skip;
60}
61
Jeff Bolz46c0ea02019-10-09 13:06:29 -050062bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060063 bool skip = false;
64 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
65 if (api_version_nopatch != effective_api_version) {
sfricke-samsung6aec21b2020-11-01 07:49:43 -080066 if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) {
67 skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070068 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
69 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
70 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060071 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070072 skip |= LogWarning(instance, kVUIDUndefined,
73 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
74 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
75 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060076 }
77 }
78 return skip;
79}
80
Jeff Bolz46c0ea02019-10-09 13:06:29 -050081bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060082 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060083 // Create and use a local instance extension object, as an actual instance has not been created yet
84 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
85 InstanceExtensions local_instance_extensions;
86 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
87
John Zulauf620755c2018-04-16 11:00:43 -060088 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060089 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
90 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060091 }
92
93 return skip;
94}
95
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060096bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const {
97 if (instance_extensions.vk_khr_get_physical_device_properties_2) {
98 // Struct is legal IF it's supported
99 const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device);
100 if (dev_exts_enumerated == device_extensions_enumerated.end()) return true;
101 auto enum_iter = dev_exts_enumerated->second.find(ext_name);
102 if (enum_iter != dev_exts_enumerated->second.cend()) {
103 return true;
104 }
105 }
106 return false;
107}
108
Tony-LunarG866843d2020-05-13 11:22:42 -0600109bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
110 const VkValidationFeaturesEXT *validation_features) const {
111 bool skip = false;
112 bool debug_printf = false;
113 bool gpu_assisted = false;
114 bool reserve_slot = false;
115 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
116 switch (validation_features->pEnabledValidationFeatures[i]) {
117 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
118 gpu_assisted = true;
119 break;
120
121 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
122 debug_printf = true;
123 break;
124
125 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
126 reserve_slot = true;
127 break;
128
129 default:
130 break;
131 }
132 }
133 if (reserve_slot && !gpu_assisted) {
134 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
135 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
136 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
137 }
138 if (gpu_assisted && debug_printf) {
139 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
140 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
141 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
142 }
143
144 return skip;
145}
146
John Zulauf620755c2018-04-16 11:00:43 -0600147template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700148ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
149 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600150 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700151 ExtEnabled state =
152 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600153 return state;
154}
155
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700156bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500157 const VkAllocationCallbacks *pAllocator,
158 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700159 bool skip = false;
160 // Note: From the spec--
161 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
162 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
163 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700164 ? pCreateInfo->pApplicationInfo->apiVersion
165 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700166 skip |= validate_api_version(local_api_version, api_version);
167 skip |= validate_instance_extensions(pCreateInfo);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700168 const auto *validation_features = LvlFindInChain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
Tony-LunarG866843d2020-05-13 11:22:42 -0600169 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
170
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700171 return skip;
172}
173
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700174void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700175 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
176 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700177 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
178 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700179 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700180 this->instance_extensions = instance_data->instance_extensions;
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700181}
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600182
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700183void StatelessValidation::CommonPostCallRecordEnumeratePhysicalDevice(const VkPhysicalDevice *phys_devices, const int count) {
184 // Assume phys_devices is valid
185 assert(phys_devices);
186 for (int i = 0; i < count; ++i) {
187 const auto &phys_device = phys_devices[i];
188 if (0 == physical_device_properties_map.count(phys_device)) {
189 auto phys_dev_props = new VkPhysicalDeviceProperties;
190 DispatchGetPhysicalDeviceProperties(phys_device, phys_dev_props);
191 physical_device_properties_map[phys_device] = phys_dev_props;
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600192
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700193 // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state
194 uint32_t ext_count = 0;
Jeremy Gebbencbf22862021-03-03 12:01:22 -0700195 layer_data::unordered_set<std::string> dev_exts_enumerated{};
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700196 std::vector<VkExtensionProperties> ext_props{};
197 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, nullptr);
198 ext_props.resize(ext_count);
199 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, ext_props.data());
200 for (uint32_t j = 0; j < ext_count; j++) {
201 dev_exts_enumerated.insert(ext_props[j].extensionName);
202 }
203 device_extensions_enumerated[phys_device] = std::move(dev_exts_enumerated);
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600204 }
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700205 }
206}
207
208void StatelessValidation::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
209 VkPhysicalDevice *pPhysicalDevices, VkResult result) {
210 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
211 return;
212 }
213
214 if (pPhysicalDeviceCount && pPhysicalDevices) {
215 CommonPostCallRecordEnumeratePhysicalDevice(pPhysicalDevices, *pPhysicalDeviceCount);
216 }
217}
218
219void StatelessValidation::PostCallRecordEnumeratePhysicalDeviceGroups(
220 VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties,
221 VkResult result) {
222 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
223 return;
224 }
225
226 if (pPhysicalDeviceGroupCount && pPhysicalDeviceGroupProperties) {
227 for (uint32_t i = 0; i < *pPhysicalDeviceGroupCount; i++) {
228 const auto &group = pPhysicalDeviceGroupProperties[i];
229 CommonPostCallRecordEnumeratePhysicalDevice(group.physicalDevices, group.physicalDeviceCount);
230 }
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600231 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700232}
233
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600234void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
235 for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) {
236 delete (it->second);
237 it = physical_device_properties_map.erase(it);
238 }
239};
240
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700241void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700242 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700243 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700244 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700245 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
246 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700247
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700248 // Parmeter validation also uses extension data
249 stateless_validation->device_extensions = this->device_extensions;
250
251 VkPhysicalDeviceProperties device_properties = {};
252 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600253 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700254 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
255
256 if (device_extensions.vk_nv_shading_rate_image) {
257 // Get the needed shading rate image limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700258 auto shading_rate_image_props = LvlInitStruct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
259 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600260 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700261 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
262 }
263
264 if (device_extensions.vk_nv_mesh_shader) {
265 // Get the needed mesh shader limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700266 auto mesh_shader_props = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesNV>();
267 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600268 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700269 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
270 }
271
Jason Macnak5c954952019-07-09 15:46:12 -0700272 if (device_extensions.vk_nv_ray_tracing) {
273 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700274 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPropertiesNV>();
275 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jason Macnak5c954952019-07-09 15:46:12 -0700276 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500277 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
278 }
279
sourav parmarcd5fb182020-07-17 12:58:44 -0700280 if (device_extensions.vk_khr_ray_tracing_pipeline) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500281 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700282 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>();
283 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500284 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
285 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700286 }
287
sourav parmarcd5fb182020-07-17 12:58:44 -0700288 if (device_extensions.vk_khr_acceleration_structure) {
289 // Get the needed ray tracing acc structure limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700290 auto acc_structure_props = LvlInitStruct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>();
291 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&acc_structure_props);
sourav parmarcd5fb182020-07-17 12:58:44 -0700292 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
293 phys_dev_ext_props.acc_structure_props = acc_structure_props;
294 }
295
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700296 if (device_extensions.vk_ext_transform_feedback) {
297 // Get the needed transform feedback limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700298 auto transform_feedback_props = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
299 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&transform_feedback_props);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700300 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
301 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
302 }
303
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800304 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
305
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700306 // Save app-enabled features in this device's validation object
307 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700308 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200309 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
310 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
311 if (features2) {
312 tmp_features2_state.features = features2->features;
313 } else if (pCreateInfo->pEnabledFeatures) {
314 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700315 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200316 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700317 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200318 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700319 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200320 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700321}
322
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700323bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500324 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600325 bool skip = false;
326
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200327 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
328 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
329 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600330 }
331
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700332 // If this device supports VK_KHR_portability_subset, it must be enabled
333 const std::string portability_extension_name("VK_KHR_portability_subset");
334 const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice);
335 const bool portability_supported = dev_extensions.count(portability_extension_name) != 0;
336 bool portability_requested = false;
337
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200338 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
339 skip |=
340 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
341 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
342 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
343 pCreateInfo->ppEnabledExtensionNames[i]);
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700344 if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) {
345 portability_requested = true;
346 }
347 }
348
349 if (portability_supported && !portability_requested) {
350 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451",
351 "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it",
352 report_data->FormatHandle(physicalDevice).c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600353 }
354
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200355 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700356 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
357 bool negative_viewport =
358 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200359 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700360 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
361 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
362 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200363 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600364 }
365
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600366 {
367 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
368 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
369 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700370 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
371 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
372 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600373 }
374 }
375
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600376 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
377 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700378 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600379 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800380 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700381 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800382 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700383 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600384 }
385 }
386
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700387 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500388 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700389 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500390 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
391 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
392 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
393 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700394 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700395 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
396 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
397 skip |= LogError(
398 device,
399 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
400 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
401 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700402 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700403 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600404 if (vertex_attribute_divisor_features && (!device_extensions.vk_ext_vertex_attribute_divisor)) {
405 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
406 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
407 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600408 }
409
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700410 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700411 if (vulkan_11_features) {
412 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
413 while (current) {
414 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
415 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
416 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
417 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
418 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
419 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700420 skip |= LogError(
421 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700422 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
423 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
424 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
425 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
426 break;
427 }
428 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
429 }
sfricke-samsungebda6792021-01-16 08:57:52 -0800430
431 // Check features are enabled if matching extension is passed in as well
432 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
433 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
434 if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
435 (vulkan_11_features->shaderDrawParameters == VK_FALSE)) {
436 skip |= LogError(
437 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-04476",
438 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.",
439 VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
440 }
441 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700442 }
443
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700444 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700445 if (vulkan_12_features) {
446 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
447 while (current) {
448 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
449 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
450 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
451 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
452 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
453 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
454 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
455 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
456 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
457 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
458 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
459 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
460 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700461 skip |= LogError(
462 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700463 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
464 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
465 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
466 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
467 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
468 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
469 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
470 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
471 break;
472 }
473 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
474 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700475 // Check features are enabled if matching extension is passed in as well
476 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
477 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
478 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
479 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
480 skip |= LogError(
481 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
482 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
483 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
484 }
485 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
486 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
487 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
488 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
489 "is not VK_TRUE.",
490 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
491 }
492 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
493 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
494 skip |= LogError(
495 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
496 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
497 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
498 }
499 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
500 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
501 skip |= LogError(
502 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
503 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
504 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
505 }
506 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
507 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
508 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
509 skip |=
510 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
511 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
512 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
513 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
514 }
515 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700516 }
517
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600518 // Validate pCreateInfo->pQueueCreateInfos
519 if (pCreateInfo->pQueueCreateInfos) {
Jeremy Gebbencbf22862021-03-03 12:01:22 -0700520 layer_data::unordered_set<uint32_t> set;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600521
522 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700523 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
524 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600525 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700526 skip |=
527 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
528 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
529 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
530 "index value.",
531 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600532 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700533 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
534 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
535 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
536 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600537 } else {
538 set.insert(requested_queue_family);
539 }
540
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700541 if (queue_create_info.pQueuePriorities != nullptr) {
542 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
543 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600544 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700545 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
546 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
547 "] (=%f) is not between 0 and 1 (inclusive).",
548 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600549 }
550 }
551 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700552
553 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700554 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700555 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700556 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700557 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700558 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700559 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700560 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700561 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700562 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700563 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
564 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
565 "protectedMemory feature being set as well.");
566 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600567 }
568 }
569
sfricke-samsung30a57412020-05-15 21:14:54 -0700570 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700571 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700572 VkBool32 variable_pointers = VK_FALSE;
573 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700574 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700575 variable_pointers = vulkan_11_features->variablePointers;
576 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700577 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700578 variable_pointers = variable_pointers_features->variablePointers;
579 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700580 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700581 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700582 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
583 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
584 }
585
sfricke-samsungfd76c342020-05-29 23:13:43 -0700586 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700587 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700588 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700589 VkBool32 multiview_geometry_shader = VK_FALSE;
590 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700591 if (vulkan_11_features) {
592 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700593 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
594 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700595 } else if (multiview_features) {
596 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700597 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
598 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700599 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700600 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700601 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
602 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
603 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700604 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700605 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
606 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
607 }
608
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600609 return skip;
610}
611
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500612bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700613 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700614 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
615 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
616 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600617 }
618
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700619 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600620}
621
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700622bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500623 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100624 bool skip = false;
625
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600626 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700627 skip |=
628 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600629
630 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
631 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
632 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
633 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700634 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
635 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
636 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600637 }
638
639 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
640 // queueFamilyIndexCount uint32_t values
641 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700642 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
643 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
644 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
645 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600646 }
647 }
648
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700649 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
650 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
651 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
652 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
653 }
654
655 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
656 skip |=
657 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
658 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
659 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
660 }
661
662 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
663 skip |=
664 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
665 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
666 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
667 }
668
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600669 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
670 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
671 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
672 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700673 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
674 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
675 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600676 }
677 }
678
679 return skip;
680}
681
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700682bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500683 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600684 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600685
686 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800687 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700688 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600689 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
690 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
691 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
692 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700693 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
694 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
695 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600696 }
697
698 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
699 // queueFamilyIndexCount uint32_t values
700 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700701 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
702 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
703 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
704 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600705 }
706 }
707
Dave Houlton413a6782018-05-22 13:01:54 -0600708 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700709 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600710 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700711 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600712 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700713 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600714
Dave Houlton413a6782018-05-22 13:01:54 -0600715 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700716 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600717 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700718 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600719
Dave Houlton130c0212018-01-29 13:39:56 -0700720 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700721 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
722 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700723 skip |= LogError(
724 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600725 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
726 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700727 }
728
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600729 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100730 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
731 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700732 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
733 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
734 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600735 }
736
737 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700738 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100739 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700740 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
741 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
742 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
743 ") are not equal.",
744 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100745 }
746
747 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700748 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
749 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
750 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
751 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100752 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600753 }
754
755 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700756 skip |= LogError(
757 device, "VUID-VkImageCreateInfo-imageType-00957",
758 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600759 }
760 }
761
Dave Houlton130c0212018-01-29 13:39:56 -0700762 // 3D image may have only 1 layer
763 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700764 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
765 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700766 }
767
Dave Houlton130c0212018-01-29 13:39:56 -0700768 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
769 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
770 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
771 // At least one of the legal attachment bits must be set
772 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700773 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
774 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700775 }
776 // No flags other than the legal attachment bits may be set
777 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
778 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700779 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
780 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700781 }
782 }
783
Jeff Bolzef40fec2018-09-01 22:04:34 -0500784 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700785 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500786 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700787 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700788 ? static_cast<uint32_t>(ceil(log2(max_dim)))
789 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
790 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600791 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700792 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
793 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
794 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600795 }
796
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700797 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700798 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
799 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
800 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600801 }
802
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700803 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700804 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
805 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
806 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100807 }
808
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700809 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700810 skip |= LogError(
811 device, "VUID-VkImageCreateInfo-flags-01924",
812 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
813 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
814 }
815
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600816 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
817 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700818 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
819 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700820 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
821 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
822 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600823 }
824
825 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700826 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600827 // Linear tiling is unsupported
828 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700829 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700830 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
831 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600832 }
833
834 // Sparse 1D image isn't valid
835 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700836 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
837 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600838 }
839
840 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700841 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700842 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
843 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
844 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600845 }
846
847 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700848 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700849 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
850 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
851 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600852 }
853
854 // Multi-sample 2D image when device doesn't support it
855 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700856 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600857 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700858 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
859 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
860 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700861 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600862 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700863 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
864 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
865 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700866 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600867 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700868 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
869 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
870 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700871 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600872 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700873 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
874 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
875 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600876 }
877 }
878 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500879
Jeff Bolz9af91c52018-09-01 21:53:57 -0500880 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
881 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700882 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
883 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
884 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500885 }
886 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700887 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
888 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
889 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500890 }
891 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700892 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
893 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
894 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500895 }
896 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500897
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700898 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600899 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700900 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
901 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
902 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500903 }
904
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700905 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700906 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
907 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800908 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
909 "depth/stencil format.",
910 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500911 }
912
Dave Houlton142c4cb2018-10-17 15:04:41 -0600913 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700914 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
915 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
916 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
917 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500918 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600919 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700920 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
921 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
922 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
923 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500924 }
925 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500926
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700927 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -0800928 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -0700929 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
930 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800931 "format (%s) must be a depth or depth/stencil format.",
932 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -0700933 }
934
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700935 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500936 if (image_stencil_struct != nullptr) {
937 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
938 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
939 // No flags other than the legal attachment bits may be set
940 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
941 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700942 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
943 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
944 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
945 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500946 }
947 }
948
sfricke-samsung61a57c02021-01-10 21:35:12 -0800949 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -0500950 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
951 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800952 skip |= LogError(
953 device, "VUID-VkImageCreateInfo-Format-02536",
954 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
955 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%u) exceeds device "
956 "maxFramebufferWidth (%u)",
957 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500958 }
959
960 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800961 skip |= LogError(
962 device, "VUID-VkImageCreateInfo-format-02537",
963 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
964 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%u) exceeds device "
965 "maxFramebufferHeight (%u)",
966 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500967 }
968 }
969
970 if (!physical_device_features.shaderStorageImageMultisample &&
971 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
972 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
973 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700974 LogError(device, "VUID-VkImageCreateInfo-format-02538",
975 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
976 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
977 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500978 }
979
980 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
981 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700982 skip |= LogError(
983 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500984 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
985 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
986 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
987 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
988 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700989 skip |= LogError(
990 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500991 "vkCreateImage(): Depth-stencil image in which usage does not include "
992 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
993 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
994 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
995 }
996
997 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
998 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700999 skip |= LogError(
1000 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001001 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1002 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1003 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1004 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1005 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001006 skip |= LogError(
1007 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001008 "vkCreateImage(): Depth-stencil image in which usage does not include "
1009 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1010 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1011 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1012 }
1013 }
1014 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001015
1016 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1017 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1018 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1019 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1020 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1021 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001022
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001023 std::vector<uint64_t> image_create_drm_format_modifiers;
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001024 if (device_extensions.vk_ext_image_drm_format_modifier) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001025 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1026 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001027 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1028 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1029 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1030 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1031 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1032 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1033 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001034 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001035 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1036 } else if (drm_format_mod_list != nullptr) {
1037 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1038 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1039 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001040 }
1041 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1042 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1043 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1044 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1045 "in the pNext chain");
1046 }
1047 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001048
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001049 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001050 bool image_create_maybe_linear = false;
1051 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1052 image_create_maybe_linear = true;
1053 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1054 image_create_maybe_linear = false;
1055 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1056 image_create_maybe_linear =
1057 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001058 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001059 }
1060
1061 // If multi-sample, validate type, usage, tiling and mip levels.
1062 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001063 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001064 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1065 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1066 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1067 }
1068
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001069 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001070 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1071 image_create_maybe_linear)) {
1072 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1073 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1074 }
1075
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001076 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1077 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1078 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1079 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1080 "imageType must be VK_IMAGE_TYPE_2D.");
1081 }
1082 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1083 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1084 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1085 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1086 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001087 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001088 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001089 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1090 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1091 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1092 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1093 }
1094 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1095 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1096 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1097 "imageType must be VK_IMAGE_TYPE_2D.");
1098 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001099 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001100 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1101 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1102 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1103 }
1104 if (pCreateInfo->mipLevels != 1) {
1105 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1106 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1107 pCreateInfo->mipLevels);
1108 }
1109 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001110
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001111 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001112 if (swapchain_create_info != nullptr) {
1113 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1114 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1115 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1116 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1117 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1118 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1119
1120 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1121 // also implicitly forces the check above that extent.depth is 1
1122 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1123 string_VkImageType(pCreateInfo->imageType));
1124 }
1125 if (pCreateInfo->mipLevels != 1) {
1126 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1127 pCreateInfo->mipLevels);
1128 }
1129 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1130 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1131 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1132 }
1133 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1134 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1135 base_message, string_VkImageTiling(pCreateInfo->tiling));
1136 }
1137 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1138 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1139 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1140 }
1141 const VkImageCreateFlags valid_flags =
1142 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001143 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001144 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001145 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001146 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001147 }
1148 }
1149 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001150
1151 // If Chroma subsampled format ( _420_ or _422_ )
1152 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1153 skip |=
1154 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1155 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1156 ") must be a multiple of 2.",
1157 string_VkFormat(image_format), pCreateInfo->extent.width);
1158 }
1159 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1160 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1161 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1162 ") must be a multiple of 2.",
1163 string_VkFormat(image_format), pCreateInfo->extent.height);
1164 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001165
1166 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1167 if (format_list_info) {
1168 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1169 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1170 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1171 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
1172 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1.",
1173 viewFormatCount);
1174 }
1175 // Check if viewFormatCount is not zero that it is all compatible
1176 for (uint32_t i = 0; i < viewFormatCount; i++) {
1177 if (FormatCompatibilityClass(format_list_info->pViewFormats[i]) != FormatCompatibilityClass(image_format)) {
1178 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-04737",
1179 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%u] (%s) and "
1180 "VkImageCreateInfo::format (%s) are not compatible.",
1181 i, string_VkFormat(format_list_info->pViewFormats[0]), string_VkFormat(image_format));
1182 }
1183 }
1184 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001185 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001186
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001187 return skip;
1188}
1189
Jeff Bolz99e3f632020-03-24 22:59:22 -05001190bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1191 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1192 bool skip = false;
1193
1194 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001195 // Validate feature set if using CUBE_ARRAY
1196 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1197 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1198 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1199 "enabling the imageCubeArray feature.");
1200 }
1201
Jeff Bolz99e3f632020-03-24 22:59:22 -05001202 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1203 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1204 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001205 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001206 pCreateInfo->subresourceRange.layerCount);
1207 }
1208 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001209 skip |= LogError(
1210 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1211 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1212 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001213 }
1214 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001215
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001216 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001217 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1218 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1219 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1220 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1221 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1222 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1223 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1224 }
1225 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1226 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1227 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1228 "not an ASTC format.",
1229 string_VkFormat(pCreateInfo->format));
1230 }
1231 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001232
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001233 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001234 if (ycbcr_conversion != nullptr) {
1235 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1236 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1237 skip |= LogError(
1238 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1239 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1240 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1241 "r swizzle = %s\n"
1242 "g swizzle = %s\n"
1243 "b swizzle = %s\n"
1244 "a swizzle = %s\n",
1245 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1246 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1247 }
1248 }
1249 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001250 }
1251 return skip;
1252}
1253
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001254bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001255 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001256 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001257
1258 // Note: for numerical correctness
1259 // - float comparisons should expect NaN (comparison always false).
1260 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1261
1262 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001263 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001264 if (v1_f <= 0.0f) return true;
1265
1266 float intpart;
1267 const float fract = modff(v1_f, &intpart);
1268
1269 assert(std::numeric_limits<float>::radix == 2);
1270 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1271 if (intpart >= u32_max_plus1) return false;
1272
1273 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001274 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001275 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001276 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001277 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001278 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001279 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001280 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001281 };
1282
1283 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1284 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1285 return (v1_f <= v2_f);
1286 };
1287
1288 // width
1289 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001290 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001291
1292 if (!(viewport.width > 0.0f)) {
1293 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001294 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1295 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001296 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1297 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001298 skip |= LogError(object, "VUID-VkViewport-width-01771",
1299 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1300 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001301 }
1302
1303 // height
1304 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001305 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001306 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001307
1308 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1309 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001310 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1311 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001312 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1313 height_healthy = false;
1314
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001315 skip |= LogError(object, "VUID-VkViewport-height-01773",
1316 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1317 ").",
1318 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001319 }
1320
1321 // x
1322 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001323 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001324 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001325 skip |= LogError(object, "VUID-VkViewport-x-01774",
1326 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1327 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001328 }
1329
1330 // x + width
1331 if (x_healthy && width_healthy) {
1332 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001333 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001334 skip |= LogError(
1335 object, "VUID-VkViewport-x-01232",
1336 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1337 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1338 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001339 }
1340 }
1341
1342 // y
1343 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001344 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001345 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001346 skip |= LogError(object, "VUID-VkViewport-y-01775",
1347 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1348 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001349 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001350 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001351 skip |= LogError(object, "VUID-VkViewport-y-01776",
1352 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1353 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001354 }
1355
1356 // y + height
1357 if (y_healthy && height_healthy) {
1358 const float boundary = viewport.y + viewport.height;
1359
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001360 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001361 skip |= LogError(object, "VUID-VkViewport-y-01233",
1362 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1363 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1364 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001365 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001366 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001367 LogError(object, "VUID-VkViewport-y-01777",
1368 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1369 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1370 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001371 }
1372 }
1373
sfricke-samsungfd06d422021-01-22 02:17:21 -08001374 // The extension was not created with a feature bit whichs prevents displaying the 2 variations of the VUIDs
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001375 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001376 // minDepth
1377 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001378 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001379 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001380 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1381 "[0.0, 1.0] range.",
1382 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001383 }
1384
1385 // maxDepth
1386 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001387 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001388 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001389 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1390 "[0.0, 1.0] range.",
1391 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001392 }
1393 }
1394
1395 return skip;
1396}
1397
Dave Houlton142c4cb2018-10-17 15:04:41 -06001398struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001399 VkShadingRatePaletteEntryNV shadingRate;
1400 uint32_t width;
1401 uint32_t height;
1402};
1403
1404// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001405static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001406 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1407 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1408 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1409 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1410 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1411 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001412};
1413
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001414bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001415 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001416
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001417 SampleOrderInfo *sample_order_info;
1418 uint32_t info_idx = 0;
1419 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1420 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1421 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001422 break;
1423 }
1424 }
1425
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001426 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001427 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1428 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1429 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001430 return skip;
1431 }
1432
Dave Houlton142c4cb2018-10-17 15:04:41 -06001433 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001434 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001435 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1436 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1437 ") must "
1438 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1439 "is set in framebufferNoAttachmentsSampleCounts.",
1440 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001441 }
1442
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001443 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001444 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1445 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1446 ") must "
1447 "be equal to the product of sampleCount (=%" PRIu32
1448 "), the fragment width for shadingRate "
1449 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001450 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001451 }
1452
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001453 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001454 skip |= LogError(
1455 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001456 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1457 ") must "
1458 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001459 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001460 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001461
1462 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001463 // the first width*height*sampleCount bits to all be set. Note: There is no
1464 // guarantee that 64 bits is enough, but practically it's unlikely for an
1465 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001466 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001467 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001468 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001469 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1470 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001471 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1472 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001473 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001474 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001475 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1476 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001477 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001478 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001479 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1480 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001481 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001482 uint32_t idx =
1483 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1484 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001485 }
1486
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001487 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1488 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001489 skip |= LogError(
1490 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001491 "The array pSampleLocations must contain exactly one entry for "
1492 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001493 }
1494
1495 return skip;
1496}
1497
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001498bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1499 uint32_t createInfoCount,
1500 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1501 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001502 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001503 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001504
1505 if (pCreateInfos != nullptr) {
1506 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001507 bool has_dynamic_viewport = false;
1508 bool has_dynamic_scissor = false;
1509 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001510 bool has_dynamic_depth_bias = false;
1511 bool has_dynamic_blend_constant = false;
1512 bool has_dynamic_depth_bounds = false;
1513 bool has_dynamic_stencil_compare = false;
1514 bool has_dynamic_stencil_write = false;
1515 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001516 bool has_dynamic_viewport_w_scaling_nv = false;
1517 bool has_dynamic_discard_rectangle_ext = false;
1518 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001519 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001520 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001521 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001522 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001523 bool has_dynamic_cull_mode = false;
1524 bool has_dynamic_front_face = false;
1525 bool has_dynamic_primitive_topology = false;
1526 bool has_dynamic_viewport_with_count = false;
1527 bool has_dynamic_scissor_with_count = false;
1528 bool has_dynamic_vertex_input_binding_stride = false;
1529 bool has_dynamic_depth_test_enable = false;
1530 bool has_dynamic_depth_write_enable = false;
1531 bool has_dynamic_depth_compare_op = false;
1532 bool has_dynamic_depth_bounds_test_enable = false;
1533 bool has_dynamic_stencil_test_enable = false;
1534 bool has_dynamic_stencil_op = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001535 if (pCreateInfos[i].pDynamicState != nullptr) {
1536 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1537 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1538 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001539 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1540 if (has_dynamic_viewport == true) {
1541 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1542 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1543 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1544 i);
1545 }
1546 has_dynamic_viewport = true;
1547 }
1548 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1549 if (has_dynamic_scissor == true) {
1550 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1551 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1552 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1553 i);
1554 }
1555 has_dynamic_scissor = true;
1556 }
1557 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1558 if (has_dynamic_line_width == true) {
1559 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1560 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1561 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1562 i);
1563 }
1564 has_dynamic_line_width = true;
1565 }
1566 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1567 if (has_dynamic_depth_bias == true) {
1568 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1569 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1570 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1571 i);
1572 }
1573 has_dynamic_depth_bias = true;
1574 }
1575 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1576 if (has_dynamic_blend_constant == true) {
1577 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1578 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1579 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1580 i);
1581 }
1582 has_dynamic_blend_constant = true;
1583 }
1584 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1585 if (has_dynamic_depth_bounds == true) {
1586 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1587 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1588 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1589 i);
1590 }
1591 has_dynamic_depth_bounds = true;
1592 }
1593 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1594 if (has_dynamic_stencil_compare == true) {
1595 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1596 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1597 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1598 i);
1599 }
1600 has_dynamic_stencil_compare = true;
1601 }
1602 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1603 if (has_dynamic_stencil_write == true) {
1604 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1605 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1606 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1607 i);
1608 }
1609 has_dynamic_stencil_write = true;
1610 }
1611 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1612 if (has_dynamic_stencil_reference == true) {
1613 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1614 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1615 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1616 i);
1617 }
1618 has_dynamic_stencil_reference = true;
1619 }
1620 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1621 if (has_dynamic_viewport_w_scaling_nv == true) {
1622 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1623 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1624 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1625 i);
1626 }
1627 has_dynamic_viewport_w_scaling_nv = true;
1628 }
1629 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1630 if (has_dynamic_discard_rectangle_ext == true) {
1631 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1632 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1633 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1634 i);
1635 }
1636 has_dynamic_discard_rectangle_ext = true;
1637 }
1638 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1639 if (has_dynamic_sample_locations_ext == true) {
1640 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1641 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1642 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1643 i);
1644 }
1645 has_dynamic_sample_locations_ext = true;
1646 }
1647 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1648 if (has_dynamic_exclusive_scissor_nv == true) {
1649 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1650 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1651 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1652 i);
1653 }
1654 has_dynamic_exclusive_scissor_nv = true;
1655 }
1656 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1657 if (has_dynamic_shading_rate_palette_nv == true) {
1658 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1659 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1660 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1661 i);
1662 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001663 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001664 }
1665 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1666 if (has_dynamic_viewport_course_sample_order_nv == true) {
1667 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1668 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1669 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1670 i);
1671 }
1672 has_dynamic_viewport_course_sample_order_nv = true;
1673 }
1674 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1675 if (has_dynamic_line_stipple == true) {
1676 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1677 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1678 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1679 i);
1680 }
1681 has_dynamic_line_stipple = true;
1682 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001683 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1684 if (has_dynamic_cull_mode) {
1685 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1686 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1687 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1688 i);
1689 }
1690 has_dynamic_cull_mode = true;
1691 }
1692 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1693 if (has_dynamic_front_face) {
1694 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1695 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1696 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1697 i);
1698 }
1699 has_dynamic_front_face = true;
1700 }
1701 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1702 if (has_dynamic_primitive_topology) {
1703 skip |= LogError(
1704 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1705 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1706 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1707 i);
1708 }
1709 has_dynamic_primitive_topology = true;
1710 }
1711 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1712 if (has_dynamic_viewport_with_count) {
1713 skip |= LogError(
1714 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1715 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1716 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1717 i);
1718 }
1719 has_dynamic_viewport_with_count = true;
1720 }
1721 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1722 if (has_dynamic_scissor_with_count) {
1723 skip |= LogError(
1724 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1725 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1726 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1727 i);
1728 }
1729 has_dynamic_scissor_with_count = true;
1730 }
1731 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1732 if (has_dynamic_vertex_input_binding_stride) {
1733 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1734 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1735 "listed twice in the "
1736 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1737 i);
1738 }
1739 has_dynamic_vertex_input_binding_stride = true;
1740 }
1741 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1742 if (has_dynamic_depth_test_enable) {
1743 skip |= LogError(
1744 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1745 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1746 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1747 i);
1748 }
1749 has_dynamic_depth_test_enable = true;
1750 }
1751 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1752 if (has_dynamic_depth_write_enable) {
1753 skip |= LogError(
1754 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1755 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1756 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1757 i);
1758 }
1759 has_dynamic_depth_write_enable = true;
1760 }
1761 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1762 if (has_dynamic_depth_compare_op) {
1763 skip |=
1764 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1765 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1766 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1767 i);
1768 }
1769 has_dynamic_depth_compare_op = true;
1770 }
1771 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1772 if (has_dynamic_depth_bounds_test_enable) {
1773 skip |= LogError(
1774 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1775 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1776 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1777 i);
1778 }
1779 has_dynamic_depth_bounds_test_enable = true;
1780 }
1781 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1782 if (has_dynamic_stencil_test_enable) {
1783 skip |= LogError(
1784 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1785 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1786 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1787 i);
1788 }
1789 has_dynamic_stencil_test_enable = true;
1790 }
1791 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1792 if (has_dynamic_stencil_op) {
1793 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1794 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1795 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1796 i);
1797 }
1798 has_dynamic_stencil_op = true;
1799 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001800 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
1801 // Not allowed for graphics pipelines
1802 skip |= LogError(
1803 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
1804 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
1805 "pCreateInfos[%d].pDynamicState->pDynamicStates[%d] but not allowed in graphic pipelines.",
1806 i, state_index);
1807 }
Petr Kraus299ba622017-11-24 03:09:03 +01001808 }
1809 }
1810
sfricke-samsung3b944422021-01-23 02:15:19 -08001811 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
1812 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
1813 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
1814 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1815 i);
1816 }
1817
1818 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
1819 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
1820 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
1821 "both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1822 i);
1823 }
1824
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001825 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04001826 if ((feedback_struct != nullptr) &&
1827 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001828 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1829 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1830 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1831 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1832 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001833 }
1834
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001835 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001836
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001837 // Collect active stages and other information
1838 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001839 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001840 bool has_eval = false;
1841 bool has_control = false;
1842 if (pCreateInfos[i].pStages != nullptr) {
1843 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1844 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1845
1846 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1847 has_control = true;
1848 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1849 has_eval = true;
1850 }
1851
1852 skip |= validate_string(
1853 "vkCreateGraphicsPipelines",
1854 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1855 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1856 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001857 }
1858
1859 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1860 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1861 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1862 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1863 pCreateInfos[i].pTessellationState,
1864 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1865 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1866
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001867 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001868 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1869
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001870 skip |= validate_struct_pnext(
1871 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1872 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
1873 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
1874 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
1875 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1876 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001877
1878 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1879 pCreateInfos[i].pTessellationState->flags,
1880 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1881 }
1882
1883 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1884 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1885 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1886 pCreateInfos[i].pInputAssemblyState,
1887 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1888 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1889
1890 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1891 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001892 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001893
1894 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1895 pCreateInfos[i].pInputAssemblyState->flags,
1896 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1897
1898 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1899 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1900 pCreateInfos[i].pInputAssemblyState->topology,
1901 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1902
1903 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1904 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1905 }
1906
1907 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001908 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001909
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001910 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001911 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1912 "vkCreateGraphicsPipelines: pararameter "
1913 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1914 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001915 }
1916
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001917 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001918 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1919 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1920 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1921 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001922 allowed_structs_vk_pipeline_vertex_input_state_create_info,
1923 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08001924 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001925 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1926 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001927 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001928 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1929 skip |=
1930 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1931 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1932 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1933 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1934 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1935
1936 skip |= validate_array(
1937 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1938 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1939 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1940 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1941
1942 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001943 for (uint32_t vertex_binding_description_index = 0;
1944 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1945 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001946 skip |= validate_ranged_enum(
1947 "vkCreateGraphicsPipelines",
1948 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1949 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001950 pCreateInfos[i]
1951 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
1952 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001953 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1954 }
1955 }
1956
1957 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001958 for (uint32_t vertex_attribute_description_index = 0;
1959 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1960 ++vertex_attribute_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001961 skip |= validate_ranged_enum(
1962 "vkCreateGraphicsPipelines",
1963 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1964 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001965 pCreateInfos[i]
1966 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
1967 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001968 "VUID-VkVertexInputAttributeDescription-format-parameter");
1969 }
1970 }
1971
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001972 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001973 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1974 "vkCreateGraphicsPipelines: pararameter "
1975 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1976 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1977 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001978 }
1979
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001980 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001981 skip |=
1982 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1983 "vkCreateGraphicsPipelines: pararameter "
1984 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1985 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1986 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001987 }
1988
Jeremy Gebbencbf22862021-03-03 12:01:22 -07001989 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001990 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1991 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001992 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1993 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001994 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1995 "vkCreateGraphicsPipelines: parameter "
1996 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1997 "(%" PRIu32 ") is not distinct.",
1998 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001999 }
2000 vertex_bindings.insert(vertex_bind_desc.binding);
2001
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002002 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002003 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2004 "vkCreateGraphicsPipelines: parameter "
2005 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
2006 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2007 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002008 }
2009
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002010 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002011 skip |=
2012 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2013 "vkCreateGraphicsPipelines: parameter "
2014 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
2015 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
2016 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002017 }
2018 }
2019
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002020 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002021 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2022 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002023 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2024 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002025 skip |= LogError(
2026 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002027 "vkCreateGraphicsPipelines: parameter "
2028 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
2029 i, d, vertex_attrib_desc.location);
2030 }
2031 attribute_locations.insert(vertex_attrib_desc.location);
2032
2033 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2034 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002035 skip |= LogError(
2036 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002037 "vkCreateGraphicsPipelines: parameter "
2038 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
2039 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
2040 i, d, vertex_attrib_desc.binding, i);
2041 }
2042
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002043 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002044 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2045 "vkCreateGraphicsPipelines: parameter "
2046 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
2047 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2048 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002049 }
2050
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002051 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002052 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2053 "vkCreateGraphicsPipelines: parameter "
2054 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
2055 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2056 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002057 }
2058
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002059 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002060 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2061 "vkCreateGraphicsPipelines: parameter "
2062 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
2063 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
2064 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002065 }
2066 }
2067 }
2068
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002069 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2070 if (has_control && has_eval) {
2071 if (pCreateInfos[i].pTessellationState == nullptr) {
2072 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
2073 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
2074 "shader stage and a tessellation evaluation shader stage, "
2075 "pCreateInfos[%d].pTessellationState must not be NULL.",
2076 i, i);
2077 } else {
2078 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2079 skip |= validate_struct_pnext(
2080 "vkCreateGraphicsPipelines",
2081 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2082 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2083 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2084 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002085
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002086 skip |= validate_reserved_flags(
2087 "vkCreateGraphicsPipelines",
2088 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2089 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002090
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002091 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2092 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2093 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2094 "vkCreateGraphicsPipelines: invalid parameter "
2095 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
2096 "should be >0 and <=%u.",
2097 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2098 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002099 }
2100 }
2101 }
2102
2103 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2104 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2105 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2106 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002107 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2108 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2109 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2110 "].pViewportState (=NULL) is not a valid pointer.",
2111 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002112 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002113 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2114
2115 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002116 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2117 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2118 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2119 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002120 }
2121
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002122 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002123 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002124 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2125 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002126 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2127 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002128 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002129 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002130 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002131 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002132 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002133 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2134 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002135 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2136 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2137 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002138 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002139
2140 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002141 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002142 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002143 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002144
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002145 auto exclusive_scissor_struct =
2146 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2147 auto shading_rate_image_struct =
2148 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2149 auto coarse_sample_order_struct =
2150 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002151 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002152 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002153 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002154 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002155
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002156 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002157 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002158 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2159 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2160 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2161 ") is not 1.",
2162 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002163 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002164
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002165 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002166 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2167 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2168 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2169 ") is not 1.",
2170 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002171 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002172
Dave Houlton142c4cb2018-10-17 15:04:41 -06002173 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2174 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002175 skip |= LogError(
2176 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2177 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2178 "disabled, but pCreateInfos[%" PRIu32
2179 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2180 ") is not 1.",
2181 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002182 }
2183
Jeff Bolz9af91c52018-09-01 21:53:57 -05002184 if (shading_rate_image_struct &&
2185 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002186 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2187 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2188 "disabled, but pCreateInfos[%" PRIu32
2189 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2190 ") is neither 0 nor 1.",
2191 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002192 }
2193
Petr Krausa6103552017-11-16 21:21:58 +01002194 } else { // multiViewport enabled
2195 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002196 if (!has_dynamic_viewport_with_count) {
2197 skip |= LogError(
2198 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2199 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2200 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002201 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002202 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2203 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2204 "].pViewportState->viewportCount (=%" PRIu32
2205 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2206 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002207 } else if (has_dynamic_viewport_with_count) {
2208 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2209 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2210 "].pViewportState->viewportCount (=%" PRIu32
2211 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2212 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002213 }
Petr Krausa6103552017-11-16 21:21:58 +01002214
2215 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002216 if (!has_dynamic_scissor_with_count) {
2217 skip |= LogError(
2218 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2219 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2220 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002221 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002222 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2223 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2224 "].pViewportState->scissorCount (=%" PRIu32
2225 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2226 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002227 } else if (has_dynamic_scissor_with_count) {
2228 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2229 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2230 "].pViewportState->scissorCount (=%" PRIu32
2231 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2232 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002233 }
2234 }
2235
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002236 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002237 skip |=
2238 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2239 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2240 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2241 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002242 }
2243
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002244 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002245 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2246 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2247 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2248 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2249 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002250 }
2251
Piers Daniell39842ee2020-07-10 16:42:33 -06002252 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2253 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002254 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2255 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2256 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2257 "].pViewportState->viewportCount (=%" PRIu32 ").",
2258 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002259 }
2260
Dave Houlton142c4cb2018-10-17 15:04:41 -06002261 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002262 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002263 skip |=
2264 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2265 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2266 ") must be zero or identical to pCreateInfos[%" PRIu32
2267 "].pViewportState->viewportCount (=%" PRIu32 ").",
2268 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002269 }
2270
Dave Houlton142c4cb2018-10-17 15:04:41 -06002271 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002272 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002273 skip |= LogError(
2274 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002275 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2276 "] "
2277 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2278 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2279 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002280 }
2281
Petr Krausa6103552017-11-16 21:21:58 +01002282 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002283 skip |= LogError(
2284 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002285 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2286 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002287 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2288 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002289 }
2290
2291 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002292 skip |= LogError(
2293 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002294 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2295 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002296 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2297 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002298 }
2299
Jeff Bolz3e71f782018-08-29 23:15:45 -05002300 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002301 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2302 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2303 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002304 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002305 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2306 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2307 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2308 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002309 }
2310
Jeff Bolz9af91c52018-09-01 21:53:57 -05002311 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002312 shading_rate_image_struct->viewportCount > 0 &&
2313 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002314 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002315 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002316 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002317 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2318 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002319 i, i);
2320 }
2321
Chris Mayer328d8212018-12-11 14:16:18 +01002322 if (vp_swizzle_struct) {
2323 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002324 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2325 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2326 " does "
2327 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2328 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002329 }
2330 }
2331
Petr Krausb3fcdb42018-01-09 22:09:09 +01002332 // validate the VkViewports
2333 if (!has_dynamic_viewport && viewport_state.pViewports) {
2334 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2335 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002336 const char *fn_name = "vkCreateGraphicsPipelines";
2337 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2338 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2339 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002340 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002341 }
2342 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002343
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002344 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002345 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2346 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2347 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2348 "VK_NV_clip_space_w_scaling extension is not enabled.",
2349 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002350 }
2351
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002352 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002353 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2354 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2355 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2356 "VK_EXT_discard_rectangles extension is not enabled.",
2357 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002358 }
2359
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002360 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002361 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2362 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2363 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2364 "VK_EXT_sample_locations extension is not enabled.",
2365 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002366 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002367
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002368 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002369 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2370 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2371 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2372 "VK_NV_scissor_exclusive extension is not enabled.",
2373 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002374 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002375
2376 if (coarse_sample_order_struct &&
2377 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2378 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002379 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2380 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2381 "] "
2382 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2383 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2384 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002385 }
2386
2387 if (coarse_sample_order_struct) {
2388 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002389 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002390 }
2391 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002392
2393 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2394 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002395 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2396 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2397 "] "
2398 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2399 ") "
2400 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2401 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002402 }
2403 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002404 skip |= LogError(
2405 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002406 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2407 "] "
2408 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2409 i);
2410 }
2411 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002412 }
2413
2414 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002415 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2416 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2417 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2418 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002419 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002420 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002421 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002422 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2423 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002424 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002425 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002426 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002427 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002428 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002429 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002430 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002431 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2432 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002433
2434 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002435 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002436 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002437 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002438
2439 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002440 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002441 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2442 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2443
2444 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002445 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002446 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2447 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002448 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002449 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002450
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002451 skip |= validate_flags(
2452 "vkCreateGraphicsPipelines",
2453 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2454 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002455 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002456
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002457 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002458 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002459 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2460 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2461
2462 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002463 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002464 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2465 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2466
2467 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002468 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002469 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2470 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2471 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002472 }
John Zulauf7acac592017-11-06 11:15:53 -07002473 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002474 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002475 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2476 "vkCreateGraphicsPipelines(): parameter "
2477 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2478 i);
John Zulauf7acac592017-11-06 11:15:53 -07002479 }
2480 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2481 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2482 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002483 skip |= LogError(
2484 device,
2485
Dave Houlton413a6782018-05-22 13:01:54 -06002486 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002487 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002488 }
2489 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002490
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002491 const auto *line_state =
2492 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002493
2494 if (line_state) {
2495 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2496 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2497 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2498 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002499 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2500 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2501 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2502 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002503 }
2504 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2505 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002506 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2507 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2508 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2509 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002510 }
2511 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2512 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002513 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2514 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2515 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2516 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002517 }
2518 }
2519 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2520 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2521 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002522 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2523 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2524 "range [1,256].",
2525 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002526 }
2527 }
2528 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002529 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002530 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2531 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002532 skip |=
2533 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2534 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2535 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2536 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002537 }
2538 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2539 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002540 skip |=
2541 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2542 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2543 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2544 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002545 }
2546 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2547 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002548 skip |=
2549 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2550 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2551 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2552 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002553 }
2554 if (line_state->stippledLineEnable) {
2555 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2556 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002557 skip |=
2558 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2559 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2560 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2561 "stippledRectangularLines feature.",
2562 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002563 }
2564 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2565 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002566 skip |=
2567 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2568 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2569 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2570 "stippledBresenhamLines feature.",
2571 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002572 }
2573 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2574 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002575 skip |=
2576 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2577 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2578 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2579 "stippledSmoothLines feature.",
2580 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002581 }
2582 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2583 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002584 skip |=
2585 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2586 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2587 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2588 "stippledRectangularLines and strictLines features.",
2589 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002590 }
2591 }
2592 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002593 }
2594
Petr Krause91f7a12017-12-14 20:57:36 +01002595 bool uses_color_attachment = false;
2596 bool uses_depthstencil_attachment = false;
2597 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002598 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002599 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2600 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002601 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002602 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002603 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002604 }
2605 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002606 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002607 }
Petr Krause91f7a12017-12-14 20:57:36 +01002608 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002609 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002610 }
2611
2612 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002613 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002614 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002615 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002616 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002617 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002618
2619 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002620 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002621 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002622 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002623
2624 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002625 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002626 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2627 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2628
2629 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002630 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002631 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2632 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2633
2634 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002635 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002636 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2637 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002638 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002639
2640 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002641 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002642 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2643 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2644
2645 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002646 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002647 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2648 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2649
2650 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002651 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002652 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2653 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002654 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002655
2656 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002657 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002658 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2659 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002660 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002661
2662 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002663 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002664 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2665 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002666 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002667
2668 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002669 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002670 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2671 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002672 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002673
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].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2677 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002678 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002679
2680 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002681 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002682 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2683 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002684 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002685
2686 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002687 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002688 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2689 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002690 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002691
2692 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002693 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002694 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2695 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002696 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002697
2698 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002699 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002700 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2701 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2702 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002703 }
2704 }
2705
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002706 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002707 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2708
Petr Krause91f7a12017-12-14 20:57:36 +01002709 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002710 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2711 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2712 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2713 pCreateInfos[i].pColorBlendState,
2714 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2715 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2716
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002717 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002718 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002719 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2720 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002721 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2722 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002723 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2724 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002725
2726 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002727 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002728 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002729 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002730
2731 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002732 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002733 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2734 pCreateInfos[i].pColorBlendState->logicOpEnable);
2735
2736 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002737 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002738 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2739 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002740 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002741 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002742
2743 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002744 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
2745 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002746 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002747 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002748 ParameterName::IndexVector{i, attachment_index}),
2749 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002750
2751 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002752 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002753 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002754 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002755 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002756 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002757 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002758
2759 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002760 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002761 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002762 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002763 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002764 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002765 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002766
2767 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002768 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002769 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002770 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002771 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002772 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002773 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002774
2775 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002776 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002777 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002778 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002779 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002780 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002781 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002782
2783 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002784 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002785 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002786 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002787 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002788 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002789 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002790
2791 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002792 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002793 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002794 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002795 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002796 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002797 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002798
2799 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002800 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002801 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002802 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002803 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002804 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002805 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002806 }
2807 }
2808
2809 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002810 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002811 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2812 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2813 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002814 }
2815
2816 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2817 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2818 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002819 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002820 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002821 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2822 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002823 }
2824 }
2825 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002826
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002827 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
2828 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01002829 if (pCreateInfos[i].basePipelineIndex != -1) {
2830 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002831 skip |=
2832 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002833 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002834 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002835 "and pCreateInfos->basePipelineIndex is not -1.",
2836 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002837 }
2838 }
2839
Petr Kraus9752aae2017-11-24 03:05:50 +01002840 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2841 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002842 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002843 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002844 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002845 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2846 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002847 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002848 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002849 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002850 skip |=
2851 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2852 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2853 "index into the pCreateInfos array, of size %d.",
2854 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002855 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002856 }
2857 }
2858
Petr Kraus9752aae2017-11-24 03:05:50 +01002859 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002860 if (!device_extensions.vk_nv_fill_rectangle) {
2861 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2862 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002863 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2864 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2865 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2866 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002867 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2868 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07002869 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002870 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002871 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2872 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2873 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002874 }
2875 } else {
2876 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2877 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2878 (physical_device_features.fillModeNonSolid == false)) {
2879 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002880 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2881 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002882 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2883 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2884 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002885 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002886 }
Petr Kraus299ba622017-11-24 03:09:03 +01002887
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002888 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002889 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002890 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2891 "The line width state is static (pCreateInfos[%" PRIu32
2892 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2893 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2894 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2895 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002896 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002897 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002898
2899 // Validate no flags not allowed are used
2900 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2901 skip |= LogError(
2902 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2903 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags must not include VK_PIPELINE_CREATE_DISPATCH_BASE", i);
2904 }
2905 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
2906 skip |= LogError(
2907 device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
2908 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR", i);
2909 }
2910 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
2911 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
2912 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags must not include "
2913 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR",
2914 i);
2915 }
2916 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
2917 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
2918 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags must not include "
2919 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR",
2920 i);
2921 }
2922 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
2923 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
2924 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags must not include "
2925 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR",
2926 i);
2927 }
2928 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
2929 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
2930 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags must not include "
2931 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR",
2932 i);
2933 }
2934 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
2935 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
2936 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags must not include "
2937 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR",
2938 i);
2939 }
2940 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
2941 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
2942 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags must not include "
2943 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR",
2944 i);
2945 }
2946 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
2947 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
2948 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags must not include "
2949 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR",
2950 i);
2951 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002952 }
2953 }
2954
2955 return skip;
2956}
2957
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002958bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2959 uint32_t createInfoCount,
2960 const VkComputePipelineCreateInfo *pCreateInfos,
2961 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002962 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002963 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002964 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002965 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002966 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002967 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002968 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04002969 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002970 skip |=
2971 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2972 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2973 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2974 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002975 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002976
2977 // Make sure compute stage is selected
2978 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002979 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2980 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2981 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002982 }
sourav parmarcd5fb182020-07-17 12:58:44 -07002983
2984 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
2985 skip |=
2986 LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
2987 "vkCreateComputePipelines(): flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR");
2988 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002989 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002990 return skip;
2991}
2992
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002993bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002994 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002995 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002996
2997 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002998 const auto &features = physical_device_features;
2999 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003000
John Zulauf71968502017-10-26 13:51:15 -06003001 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3002 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003003 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3004 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3005 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3006 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003007 }
3008
3009 // Anistropy cannot be enabled in sampler unless enabled as a feature
3010 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003011 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3012 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3013 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003014 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003015 }
John Zulauf71968502017-10-26 13:51:15 -06003016
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003017 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3018 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003019 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3020 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3021 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3022 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003023 }
3024 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003025 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3026 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3027 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3028 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003029 }
3030 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003031 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3032 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3033 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3034 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003035 }
3036 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3037 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3038 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3039 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003040 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3041 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3042 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3043 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3044 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3045 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003046 }
3047 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003048 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3049 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3050 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003051 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003052 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003053 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3054 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3055 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003056 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003057 }
3058
3059 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3060 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003061 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3062 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003063 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003064 if (sampler_reduction != nullptr) {
3065 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3066 skip |= LogError(
3067 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3068 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3069 }
3070 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003071 }
3072
3073 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3074 // valid VkBorderColor value
3075 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3076 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3077 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003078 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3079 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003080 }
3081
3082 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
3083 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003084 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003085 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
3086 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
3087 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06003088 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003089 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
3090 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
3091 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003092 }
John Zulauf275805c2017-10-26 15:34:49 -06003093
3094 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003095 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06003096 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3097 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003098 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3099 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3100 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003101 }
3102 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003103
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003104 // Check for valid Lod range
3105 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003106 skip |=
3107 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3108 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003109 }
3110
3111 // Check mipLodBias to device limit
3112 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003113 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3114 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3115 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003116 }
3117
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003118 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003119 if (sampler_conversion != nullptr) {
3120 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3121 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3122 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3123 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003124 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003125 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003126 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3127 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3128 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3129 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3130 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3131 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3132 }
3133 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003134
3135 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3136 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3137 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3138 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3139 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3140 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3141 }
3142 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3143 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3144 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3145 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3146 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3147 }
3148 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3149 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3150 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3151 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3152 pCreateInfo->minLod, pCreateInfo->maxLod);
3153 }
3154 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3155 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3156 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3157 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3158 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3159 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3160 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3161 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3162 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3163 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3164 }
3165 if (pCreateInfo->anisotropyEnable) {
3166 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3167 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3168 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3169 }
3170 if (pCreateInfo->compareEnable) {
3171 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3172 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3173 "pCreateInfo->compareEnable must be VK_FALSE");
3174 }
3175 if (pCreateInfo->unnormalizedCoordinates) {
3176 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3177 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3178 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3179 }
3180 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003181 }
3182
Tony-LunarG7337b312020-04-15 16:40:25 -06003183 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3184 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3185 if (!device_extensions.vk_ext_custom_border_color) {
3186 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3187 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3188 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3189 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003190 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003191 if (!custom_create_info) {
3192 skip |=
3193 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3194 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3195 "struct in pNext chain.\n",
3196 string_VkBorderColor(pCreateInfo->borderColor));
3197 } else {
3198 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3199 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3200 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3201 !FormatIsSampledFloat(custom_create_info->format)))) {
3202 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3203 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3204 "whose type does not match\n",
3205 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3206 ;
3207 }
3208 }
3209 }
3210
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003211 return skip;
3212}
3213
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003214bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3215 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3216 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003217 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003218 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003219
3220 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3221 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3222 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3223 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003224 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3225 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3226 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3227 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3228 ++descriptor_index) {
3229 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003230 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003231 "vkCreateDescriptorSetLayout: required parameter "
3232 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3233 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003234 }
3235 }
3236 }
3237
3238 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3239 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3240 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003241 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3242 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3243 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3244 "values.",
3245 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003246 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003247
3248 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3249 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3250 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3251 skip |=
3252 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3253 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3254 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3255 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3256 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3257 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003258 }
3259 }
3260 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003261 return skip;
3262}
3263
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003264bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3265 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003266 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003267 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3268 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3269 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003270 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3271 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003272}
3273
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003274bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3275 const VkWriteDescriptorSet *pDescriptorWrites,
3276 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003277 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003278
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003279 if (pDescriptorWrites != NULL) {
3280 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3281 // descriptorCount must be greater than 0
3282 if (pDescriptorWrites[i].descriptorCount == 0) {
3283 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003284 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3285 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003286 }
3287
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003288 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3289 if (validateDstSet) {
3290 // dstSet must be a valid VkDescriptorSet handle
3291 skip |= validate_required_handle(vkCallingFunction,
3292 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3293 pDescriptorWrites[i].dstSet);
3294 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003295
3296 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3297 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3298 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3299 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3300 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3301 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3302 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003303 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3304 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003305 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003306 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3307 "%s(): if pDescriptorWrites[%d].descriptorType is "
3308 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3309 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3310 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3311 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003312 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3313 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003314 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3315 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003316 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3317 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003318 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003319 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3320 ParameterName::IndexVector{i, descriptor_index}),
3321 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003322 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003323 }
3324 }
3325 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3326 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3327 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3328 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3329 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3330 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3331 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003332 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003333 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003334 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3335 "%s(): if pDescriptorWrites[%d].descriptorType is "
3336 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3337 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3338 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3339 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003340 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003341 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003342 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003343 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003344 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3345 ++descriptor_index) {
3346 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3347 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3348 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003349 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3350 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003351 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003352 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3353 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003354 }
3355 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003356 }
3357 }
3358 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3359 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003360 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003361 }
3362
3363 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3364 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003365 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003366 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3367 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003368 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003369 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003370 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3371 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3372 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003373 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003374 }
3375 }
3376 }
3377 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3378 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003379 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003380 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3381 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003382 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003383 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003384 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3385 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3386 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003387 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003388 }
3389 }
3390 }
3391 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003392 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3393 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003394 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003395 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003396 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3397 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3398 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3399 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3400 "accelerationStructureCount %d member equals descriptorCount %d.",
3401 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3402 pDescriptorWrites[i].descriptorCount);
3403 }
3404 // further checks only if we have right structtype
3405 if (pnext_struct) {
3406 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3407 skip |= LogError(
3408 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3409 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3410 ".",
3411 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003412 }
sourav parmarbcee7512020-12-28 14:34:49 -08003413 if (pnext_struct->accelerationStructureCount == 0) {
3414 skip |= LogError(device,
3415 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
3416 "%s(): accelerationStructureCount must be greater than 0 .");
3417 }
3418 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003419 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003420 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3421 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3422 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3423 skip |= LogError(device,
3424 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3425 "%s(): If the nullDescriptor feature is not enabled, each member of "
3426 "pAccelerationStructures must not be VK_NULL_HANDLE.");
sourav parmarcd5fb182020-07-17 12:58:44 -07003427 }
3428 }
3429 }
sourav parmarbcee7512020-12-28 14:34:49 -08003430 }
3431 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003432 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003433 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3434 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3435 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3436 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3437 "accelerationStructureCount %d member equals descriptorCount %d.",
3438 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3439 pDescriptorWrites[i].descriptorCount);
3440 }
3441 // further checks only if we have right structtype
3442 if (pnext_struct) {
3443 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3444 skip |= LogError(
3445 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3446 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3447 ".",
3448 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003449 }
sourav parmarbcee7512020-12-28 14:34:49 -08003450 if (pnext_struct->accelerationStructureCount == 0) {
3451 skip |= LogError(device,
3452 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
3453 "%s(): accelerationStructureCount must be greater than 0 .");
3454 }
3455 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003456 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003457 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3458 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3459 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3460 skip |= LogError(device,
3461 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3462 "%s(): If the nullDescriptor feature is not enabled, each member of "
3463 "pAccelerationStructures must not be VK_NULL_HANDLE.");
sourav parmarcd5fb182020-07-17 12:58:44 -07003464 }
3465 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003466 }
3467 }
3468 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003469 }
3470 }
3471 return skip;
3472}
3473
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003474bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3475 const VkWriteDescriptorSet *pDescriptorWrites,
3476 uint32_t descriptorCopyCount,
3477 const VkCopyDescriptorSet *pDescriptorCopies) const {
3478 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3479}
3480
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003481bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003482 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003483 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003484 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3485}
3486
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003487bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3488 const VkAllocationCallbacks *pAllocator,
3489 VkRenderPass *pRenderPass) const {
3490 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3491}
3492
Mike Schuchardt2df08912020-12-15 16:28:09 -08003493bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003494 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003495 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003496 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3497}
3498
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003499bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3500 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003501 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003502 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003503
3504 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3505 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3506 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003507 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3508 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003509 return skip;
3510}
3511
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003512bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003513 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003514 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003515
3516 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3517 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003518 bool cb_is_secondary;
3519 {
3520 auto lock = cb_read_lock();
3521 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3522 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003523
Tony-LunarG3c287f62020-12-17 12:39:49 -07003524 if (cb_is_secondary) {
3525 // Implicit VUs
3526 // validate only sType here; pointer has to be validated in core_validation
3527 const bool k_not_required = false;
3528 const char *k_no_vuid = nullptr;
3529 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3530 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003531 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3532 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003533
Tony-LunarG3c287f62020-12-17 12:39:49 -07003534 if (info) {
3535 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003536 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003537 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003538 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3539 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3540 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3541 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003542
Tony-LunarG3c287f62020-12-17 12:39:49 -07003543 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003544
Tony-LunarG3c287f62020-12-17 12:39:49 -07003545 // Explicit VUs
3546 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003547 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003548 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3549 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3550 cmd_name);
3551 }
3552
3553 if (physical_device_features.inheritedQueries) {
3554 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003555 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3556 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3557 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003558 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003559 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003560 }
3561
3562 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003563 skip |=
3564 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
3565 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
3566 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
3567 } else { // !pipelineStatisticsQuery
3568 skip |=
3569 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
3570 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003571 }
3572
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003573 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003574 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003575 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003576 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3577 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
3578 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003579 commandBuffer,
3580 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07003581 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3582 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3583 }
Petr Kraus139757b2019-08-15 17:19:33 +02003584 }
3585 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003586 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003587 return skip;
3588}
3589
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003590bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003591 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003592 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003593
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003594 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003595 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003596 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3597 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3598 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003599 }
3600 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003601 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3602 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3603 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003604 }
3605 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003606 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003607 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003608 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3609 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3610 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3611 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003612 }
3613 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003614
3615 if (pViewports) {
3616 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3617 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003618 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003619 skip |= manual_PreCallValidateViewport(
3620 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003621 }
3622 }
3623
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003624 return skip;
3625}
3626
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003627bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003628 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003629 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003630
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003631 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003632 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003633 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3634 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3635 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003636 }
3637 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003638 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3639 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3640 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003641 }
3642 } else { // multiViewport enabled
3643 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003644 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003645 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3646 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3647 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3648 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003649 }
3650 }
3651
Petr Kraus6260f0a2018-02-27 21:15:55 +01003652 if (pScissors) {
3653 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3654 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003655
Petr Kraus6260f0a2018-02-27 21:15:55 +01003656 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003657 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3658 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3659 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003660 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003661
Petr Kraus6260f0a2018-02-27 21:15:55 +01003662 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003663 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3664 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3665 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003666 }
3667
3668 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3669 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003670 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3671 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3672 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3673 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003674 }
3675
3676 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3677 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003678 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3679 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3680 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3681 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003682 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003683 }
3684 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003685
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003686 return skip;
3687}
3688
Jeff Bolz5c801d12019-10-09 10:38:45 -05003689bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003690 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003691
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003692 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003693 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3694 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003695 }
3696
3697 return skip;
3698}
3699
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003700bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003701 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003702 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003703
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003704 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003705 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003706 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
3707 }
3708 if (drawCount > device_limits.maxDrawIndirectCount) {
3709 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003710 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
3711 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003712 }
3713 return skip;
3714}
3715
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003716bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003717 VkDeviceSize offset, uint32_t drawCount,
3718 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003719 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003720 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003721 skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
3722 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
3723 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003724 }
3725 if (drawCount > device_limits.maxDrawIndirectCount) {
3726 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003727 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).",
3728 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003729 }
3730 return skip;
3731}
3732
sfricke-samsungf692b972020-05-02 08:00:45 -07003733bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3734 VkDeviceSize countBufferOffset, bool khr) const {
3735 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003736 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003737 if (offset & 3) {
3738 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003739 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003740 }
3741
3742 if (countBufferOffset & 3) {
3743 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003744 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003745 countBufferOffset);
3746 }
3747 return skip;
3748}
3749
3750bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3751 VkDeviceSize offset, VkBuffer countBuffer,
3752 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3753 uint32_t stride) const {
3754 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3755}
3756
3757bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3758 VkDeviceSize offset, VkBuffer countBuffer,
3759 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3760 uint32_t stride) const {
3761 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3762}
3763
3764bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3765 VkDeviceSize countBufferOffset, bool khr) const {
3766 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003767 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003768 if (offset & 3) {
3769 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003770 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003771 }
3772
3773 if (countBufferOffset & 3) {
3774 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003775 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003776 countBufferOffset);
3777 }
3778 return skip;
3779}
3780
3781bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3782 VkDeviceSize offset, VkBuffer countBuffer,
3783 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3784 uint32_t stride) const {
3785 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3786}
3787
3788bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3789 VkDeviceSize offset, VkBuffer countBuffer,
3790 VkDeviceSize countBufferOffset,
3791 uint32_t maxDrawCount, uint32_t stride) const {
3792 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3793}
3794
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003795bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3796 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003797 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003798 bool skip = false;
3799 for (uint32_t rect = 0; rect < rectCount; rect++) {
3800 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003801 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3802 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003803 }
sfricke-samsung10867682020-04-25 02:20:39 -07003804 if (pRects[rect].rect.extent.width == 0) {
3805 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3806 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3807 }
3808 if (pRects[rect].rect.extent.height == 0) {
3809 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3810 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3811 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003812 }
3813 return skip;
3814}
3815
Andrew Fobel3abeb992020-01-20 16:33:22 -05003816bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3817 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3818 VkImageFormatProperties2 *pImageFormatProperties,
3819 const char *apiName) const {
3820 bool skip = false;
3821
3822 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003823 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003824 if (image_stencil_struct != nullptr) {
3825 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3826 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3827 // No flags other than the legal attachment bits may be set
3828 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3829 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003830 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3831 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3832 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3833 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3834 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003835 }
3836 }
3837 }
3838 }
3839
3840 return skip;
3841}
3842
3843bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3844 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3845 VkImageFormatProperties2 *pImageFormatProperties) const {
3846 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3847 "vkGetPhysicalDeviceImageFormatProperties2");
3848}
3849
3850bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3851 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3852 VkImageFormatProperties2 *pImageFormatProperties) const {
3853 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3854 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3855}
3856
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03003857bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
3858 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
3859 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
3860 bool skip = false;
3861
3862 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
3863 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
3864 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
3865 }
3866
3867 return skip;
3868}
3869
sfricke-samsung3999ef62020-02-09 17:05:59 -08003870bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3871 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3872 bool skip = false;
3873
3874 if (pRegions != nullptr) {
3875 for (uint32_t i = 0; i < regionCount; i++) {
3876 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003877 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3878 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003879 }
3880 }
3881 }
3882 return skip;
3883}
3884
Jeff Leger178b1e52020-10-05 12:22:23 -04003885bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
3886 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
3887 bool skip = false;
3888
3889 if (pCopyBufferInfo->pRegions != nullptr) {
3890 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
3891 if (pCopyBufferInfo->pRegions[i].size == 0) {
3892 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
3893 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
3894 }
3895 }
3896 }
3897 return skip;
3898}
3899
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003900bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003901 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3902 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003903 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003904
3905 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003906 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3907 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3908 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003909 }
3910
3911 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003912 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3913 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3914 "), must be greater than zero and less than or equal to 65536.",
3915 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003916 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003917 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3918 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3919 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003920 }
3921 return skip;
3922}
3923
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003924bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003925 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003926 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003927
3928 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003929 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3930 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3931 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003932 }
3933
3934 if (size != VK_WHOLE_SIZE) {
3935 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003936 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003937 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3938 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003939 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003940 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3941 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003942 }
3943 }
3944 return skip;
3945}
3946
sfricke-samsunga1d00272021-03-10 21:37:41 -08003947bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003948 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003949
3950 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003951 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3952 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3953 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3954 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003955 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08003956 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3957 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
3958 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003959 }
3960
3961 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3962 // queueFamilyIndexCount uint32_t values
3963 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003964 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08003965 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003966 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08003967 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
3968 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003969 }
3970 }
3971
Dave Houlton413a6782018-05-22 13:01:54 -06003972 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08003973 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003974
sfricke-samsunga1d00272021-03-10 21:37:41 -08003975 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
3976 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
3977 if (format_list_info) {
3978 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
3979 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
3980 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
3981 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
3982 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1 if it is in the pNext chain.",
3983 func_name, viewFormatCount);
3984 }
3985
3986 // Using the first format, compare the rest of the formats against it that they are compatible
3987 for (uint32_t i = 1; i < viewFormatCount; i++) {
3988 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
3989 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
3990 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
3991 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
3992 "VkImageFormatListCreateInfo::pViewFormats[%u] (%s) are not compatible in the pNext chain.",
3993 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
3994 string_VkFormat(format_list_info->pViewFormats[i]));
3995 }
3996 }
3997 }
3998
3999 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4000 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4001 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4002 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4003 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4004 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4005 func_name);
4006 } else {
4007 if (format_list_info == nullptr) {
4008 skip |= LogError(
4009 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4010 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4011 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4012 func_name);
4013 } else if (format_list_info->viewFormatCount == 0) {
4014 skip |= LogError(
4015 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4016 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4017 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4018 func_name);
4019 } else {
4020 bool found_base_format = false;
4021 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4022 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4023 found_base_format = true;
4024 break;
4025 }
4026 }
4027 if (!found_base_format) {
4028 skip |=
4029 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4030 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4031 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4032 "pCreateInfo->imageFormat.",
4033 func_name);
4034 }
4035 }
4036 }
4037 }
4038 }
4039 return skip;
4040}
4041
4042bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4043 const VkAllocationCallbacks *pAllocator,
4044 VkSwapchainKHR *pSwapchain) const {
4045 bool skip = false;
4046 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4047 return skip;
4048}
4049
4050bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4051 const VkSwapchainCreateInfoKHR *pCreateInfos,
4052 const VkAllocationCallbacks *pAllocator,
4053 VkSwapchainKHR *pSwapchains) const {
4054 bool skip = false;
4055 if (pCreateInfos) {
4056 for (uint32_t i = 0; i < swapchainCount; i++) {
4057 std::stringstream func_name;
4058 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4059 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4060 }
4061 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004062 return skip;
4063}
4064
Jeff Bolz5c801d12019-10-09 10:38:45 -05004065bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004066 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004067
4068 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004069 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004070 if (present_regions) {
4071 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004072 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004073 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4074 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004075 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004076 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4077 "extension swapchainCount is %i. These values must be equal.",
4078 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004079 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004080 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004081 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4082 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004083 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4084 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4085 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004086 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004087 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004088 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004089 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004090 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004091 }
4092 }
4093
4094 return skip;
4095}
4096
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004097bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4098 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4099 const VkAllocationCallbacks *pAllocator,
4100 VkDisplayModeKHR *pMode) const {
4101 bool skip = false;
4102
4103 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4104 if (display_mode_parameters.visibleRegion.width == 0) {
4105 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4106 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4107 }
4108 if (display_mode_parameters.visibleRegion.height == 0) {
4109 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4110 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4111 }
4112 if (display_mode_parameters.refreshRate == 0) {
4113 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4114 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4115 }
4116
4117 return skip;
4118}
4119
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004120#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004121bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4122 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4123 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004124 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004125 bool skip = false;
4126
4127 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004128 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4129 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004130 }
4131
4132 return skip;
4133}
4134#endif // VK_USE_PLATFORM_WIN32_KHR
4135
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004136bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004137 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004138 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004139 bool skip = false;
4140
4141 if (pCreateInfo) {
4142 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004143 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4144 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004145 }
4146
4147 if (pCreateInfo->pPoolSizes) {
4148 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4149 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004150 skip |= LogError(
4151 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004152 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004153 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004154 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4155 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004156 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4157 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4158 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4159 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4160 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004161 }
Petr Krausc8655be2017-09-27 18:56:51 +02004162 }
4163 }
4164 }
4165
4166 return skip;
4167}
4168
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004169bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004170 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004171 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004172
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004173 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004174 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004175 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4176 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4177 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004178 }
4179
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004180 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004181 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004182 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4183 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4184 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004185 }
4186
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004187 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004188 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004189 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4190 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4191 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004192 }
4193
4194 return skip;
4195}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004196
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004197bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004198 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004199 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004200
4201 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004202 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
4203 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07004204 }
4205 return skip;
4206}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004207
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004208bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4209 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004210 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004211 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004212
4213 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004214 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004215 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004216 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4217 "vkCmdDispatch(): baseGroupX (%" PRIu32
4218 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4219 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004220 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004221 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4222 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4223 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4224 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004225 }
4226
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004227 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004228 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004229 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4230 "vkCmdDispatch(): baseGroupY (%" PRIu32
4231 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4232 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004233 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004234 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4235 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4236 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4237 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004238 }
4239
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004240 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004241 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004242 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4243 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4244 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4245 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004246 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004247 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4248 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4249 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4250 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004251 }
4252
4253 return skip;
4254}
4255
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004256bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4257 VkPipelineBindPoint pipelineBindPoint,
4258 VkPipelineLayout layout, uint32_t set,
4259 uint32_t descriptorWriteCount,
4260 const VkWriteDescriptorSet *pDescriptorWrites) const {
4261 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4262}
4263
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004264bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4265 uint32_t firstExclusiveScissor,
4266 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004267 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004268 bool skip = false;
4269
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004270 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004271 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004272 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004273 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4274 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4275 ") is not 0.",
4276 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004277 }
4278 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004279 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004280 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4281 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4282 ") is not 1.",
4283 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004284 }
4285 } else { // multiViewport enabled
4286 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004287 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004288 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4289 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4290 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4291 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004292 }
4293 }
4294
Jeff Bolz3e71f782018-08-29 23:15:45 -05004295 if (pExclusiveScissors) {
4296 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4297 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4298
4299 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004300 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4301 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4302 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004303 }
4304
4305 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004306 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4307 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4308 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004309 }
4310
4311 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4312 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004313 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4314 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4315 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4316 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004317 }
4318
4319 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4320 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004321 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4322 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4323 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4324 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004325 }
4326 }
4327 }
4328
4329 return skip;
4330}
4331
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004332bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4333 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004334 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004335 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004336 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4337 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4338 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4339 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4340 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4341 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004342 }
4343
4344 return skip;
4345}
4346
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004347bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4348 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004349 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004350 bool skip = false;
4351
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004352 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004353 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004354 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004355 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4356 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4357 ") is not 0.",
4358 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004359 }
4360 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004361 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004362 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4363 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4364 ") is not 1.",
4365 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004366 }
4367 }
4368
Jeff Bolz9af91c52018-09-01 21:53:57 -05004369 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004370 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004371 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4372 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4373 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4374 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004375 }
4376
4377 return skip;
4378}
4379
Jeff Bolz5c801d12019-10-09 10:38:45 -05004380bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4381 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4382 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004383 bool skip = false;
4384
Dave Houlton142c4cb2018-10-17 15:04:41 -06004385 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004386 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4387 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4388 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004389 }
4390
4391 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004392 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004393 }
4394
4395 return skip;
4396}
4397
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004398bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004399 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004400 bool skip = false;
4401
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004402 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004403 skip |= LogError(
4404 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004405 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4406 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004407 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004408 }
4409
4410 return skip;
4411}
4412
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004413bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4414 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004415 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004416 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004417 static const int condition_multiples = 0b0011;
4418 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004419 skip |= LogError(
4420 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004421 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004422 }
Lockee1c22882019-06-10 16:02:54 -06004423 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004424 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4425 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4426 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4427 stride);
Lockee1c22882019-06-10 16:02:54 -06004428 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004429 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004430 skip |= LogError(
4431 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4432 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004433 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004434 if (drawCount > device_limits.maxDrawIndirectCount) {
4435 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004436 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4437 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004438 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004439 return skip;
4440}
4441
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004442bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4443 VkDeviceSize offset, VkBuffer countBuffer,
4444 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004445 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004446 bool skip = false;
4447
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004448 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004449 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4450 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4451 "), is not a multiple of 4.",
4452 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004453 }
4454
4455 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004456 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4457 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4458 "), is not a multiple of 4.",
4459 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004460 }
4461
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004462 return skip;
4463}
4464
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004465bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004466 const VkAllocationCallbacks *pAllocator,
4467 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004468 bool skip = false;
4469
4470 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4471 if (pCreateInfo != nullptr) {
4472 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4473 // VkQueryPipelineStatisticFlagBits values
4474 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4475 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004476 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4477 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4478 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4479 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004480 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004481 if (pCreateInfo->queryCount == 0) {
4482 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4483 "vkCreateQueryPool(): queryCount must be greater than zero.");
4484 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004485 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004486 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004487}
4488
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004489bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4490 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004491 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004492 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4493 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004494}
4495
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004496void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004497 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4498 VkResult result) {
4499 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004500 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004501}
4502
Mike Schuchardt2df08912020-12-15 16:28:09 -08004503void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004504 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4505 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004506 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004507 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004508 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004509}
4510
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004511void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4512 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004513 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004514 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004515 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004516}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004517
Tony-LunarG3c287f62020-12-17 12:39:49 -07004518void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004519 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004520 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
4521 auto lock = cb_write_lock();
4522 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06004523 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004524 }
4525 }
4526}
4527
4528void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004529 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004530 auto lock = cb_write_lock();
4531 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
4532 secondary_cb_map.erase(pCommandBuffers[cb_index]);
4533 }
4534}
4535
4536void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004537 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004538 auto lock = cb_write_lock();
4539 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
4540 if (item->second == commandPool) {
4541 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004542 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004543 ++item;
4544 }
4545 }
4546}
4547
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004548bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004549 const VkAllocationCallbacks *pAllocator,
4550 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004551 bool skip = false;
4552
4553 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004554 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004555 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004556 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4557 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004558 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004559
4560 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004561 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004562 if (flags_info) {
4563 flags = flags_info->flags;
4564 }
4565
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004566 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004567 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08004568 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004569 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4570 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08004571 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004572 }
4573
4574#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004575 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004576#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004577 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4578 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004579#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004580 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004581#endif
4582
4583 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004584 skip |= LogError(
4585 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004586 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4587 }
4588 if (
4589#ifdef VK_USE_PLATFORM_WIN32_KHR
4590 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4591#endif
4592 (import_memory_fd && import_memory_fd->handleType) ||
4593#ifdef VK_USE_PLATFORM_ANDROID_KHR
4594 (import_memory_ahb && import_memory_ahb->buffer) ||
4595#endif
4596 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004597 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4598 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004599 }
4600 }
4601
4602 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004603 VkBool32 capture_replay = false;
4604 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004605 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004606 if (vulkan_12_features) {
4607 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4608 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4609 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004610 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004611 if (bda_features) {
4612 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4613 buffer_device_address = bda_features->bufferDeviceAddress;
4614 }
4615 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004616 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004617 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004618 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004619 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004620 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004621 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004622 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004623 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004624 }
4625 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004626 }
4627 return skip;
4628}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004629
Jason Macnak192fa0e2019-07-26 15:07:16 -07004630bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004631 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004632 bool skip = false;
4633
4634 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4635 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4636 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004637 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004638 } else {
4639 uint32_t vertex_component_size = 0;
4640 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4641 vertex_component_size = 4;
4642 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4643 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4644 vertex_component_size = 2;
4645 }
4646 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004647 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004648 }
4649 }
4650
4651 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4652 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004653 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004654 } else {
4655 uint32_t index_element_size = 0;
4656 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4657 index_element_size = 4;
4658 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4659 index_element_size = 2;
4660 }
4661 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004662 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004663 }
4664 }
4665 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4666 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004667 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004668 }
4669 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004670 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004671 }
4672 }
4673
4674 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004675 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004676 }
4677
4678 return skip;
4679}
4680
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004681bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4682 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004683 bool skip = false;
4684
4685 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004686 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004687 }
4688 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004689 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004690 }
4691
4692 return skip;
4693}
4694
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004695bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4696 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004697 bool skip = false;
4698 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004699 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004700 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004701 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004702 }
4703 return skip;
4704}
4705
4706bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004707 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004708 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004709 bool skip = false;
4710 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004711 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4712 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4713 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004714 }
4715 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004716 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4717 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4718 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004719 }
4720 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4721 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004722 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4723 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4724 "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 -07004725 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004726 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004727 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004728 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4729 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004730 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4731 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004732 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004733 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004734 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4735 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4736 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004737 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004738 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004739 uint64_t total_triangle_count = 0;
4740 for (uint32_t i = 0; i < info.geometryCount; i++) {
4741 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004742
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004743 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004744
Jason Macnak5c954952019-07-09 15:46:12 -07004745 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4746 continue;
4747 }
4748 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4749 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004750 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004751 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4752 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4753 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004754 }
4755 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004756 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4757 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4758 for (uint32_t i = 1; i < info.geometryCount; i++) {
4759 const VkGeometryNV &geometry = info.pGeometries[i];
4760 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004761 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004762 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4763 "info.pGeometries[0].geometryType.",
4764 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004765 }
4766 }
4767 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004768 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4769 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4770 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4771 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4772 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4773 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4774 }
4775 }
4776 skip |=
4777 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004778 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004779 return skip;
4780}
4781
Ricardo Garciaa4935972019-02-21 17:43:18 +01004782bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4783 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004784 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004785 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004786 if (pCreateInfo) {
4787 if ((pCreateInfo->compactedSize != 0) &&
4788 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004789 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4790 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4791 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4792 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004793 }
Jason Macnak5c954952019-07-09 15:46:12 -07004794
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004795 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004796 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004797 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004798 return skip;
4799}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004800
Jeff Bolz5c801d12019-10-09 10:38:45 -05004801bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4802 const VkAccelerationStructureInfoNV *pInfo,
4803 VkBuffer instanceData, VkDeviceSize instanceOffset,
4804 VkBool32 update, VkAccelerationStructureNV dst,
4805 VkAccelerationStructureNV src, VkBuffer scratch,
4806 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004807 bool skip = false;
4808
4809 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004810 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004811 }
4812
4813 return skip;
4814}
4815
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004816bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4817 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4818 VkAccelerationStructureKHR *pAccelerationStructure) const {
4819 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07004820 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004821 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07004822 if (!acceleration_structure_features ||
4823 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
4824 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
4825 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
4826 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004827 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004828 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
4829 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004830 (acceleration_structure_features &&
4831 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07004832 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07004833 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
4834 "vkCreateAccelerationStructureKHR(): If createFlags includes "
4835 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
4836 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07004837 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004838 if (pCreateInfo->deviceAddress &&
4839 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
4840 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
4841 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
4842 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
4843 }
4844 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
4845 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
4846 "vkCreateAccelerationStructureKHR(): offset must be a multiple of 256 bytes", pCreateInfo->offset);
4847 }
sourav parmar83c31b12020-05-06 12:30:54 -07004848 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004849 return skip;
4850}
4851
Jason Macnak5c954952019-07-09 15:46:12 -07004852bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4853 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004854 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004855 bool skip = false;
4856 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004857 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4858 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004859 }
4860 return skip;
4861}
4862
sourav parmarcd5fb182020-07-17 12:58:44 -07004863bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
4864 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
4865 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
4866 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07004867 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004868 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-03432",
4869 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07004870 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07004871 }
4872 return skip;
4873}
4874
Peter Chen85366392019-05-14 15:20:11 -04004875bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4876 uint32_t createInfoCount,
4877 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4878 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004879 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004880 bool skip = false;
4881
4882 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004883 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04004884 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004885 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004886 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4887 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4888 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4889 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004890 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004891
4892 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004893 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07004894 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4895 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4896 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4897 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4898 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4899 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4900 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4901 }
4902 }
4903
sourav parmarf4a78252020-04-10 13:04:21 -07004904 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4905 skip |=
4906 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4907 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4908 }
4909 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4910 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4911 skip |=
4912 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4913 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4914 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4915 }
4916 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4917 if (pCreateInfos[i].basePipelineIndex != -1) {
4918 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4919 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4920 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4921 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4922 "and pCreateInfos->basePipelineIndex is not -1.");
4923 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004924 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004925 skip |=
4926 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
4927 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
4928 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
4929 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
4930 "that element.");
4931 }
sourav parmarf4a78252020-04-10 13:04:21 -07004932 }
4933 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004934 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004935 skip |=
4936 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4937 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4938 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4939 "commands pCreateInfos parameter.");
4940 }
4941 } else {
4942 if (pCreateInfos[i].basePipelineIndex != -1) {
4943 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4944 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4945 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4946 }
4947 }
4948 }
4949 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4950 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4951 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4952 }
4953 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4954 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4955 "vkCreateRayTracingPipelinesNV: flags must not include "
4956 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4957 }
4958 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4959 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4960 "vkCreateRayTracingPipelinesNV: flags must not include "
4961 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4962 }
4963 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4964 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4965 "vkCreateRayTracingPipelinesNV: flags must not include "
4966 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4967 }
4968 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4969 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4970 "vkCreateRayTracingPipelinesNV: flags must not include "
4971 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4972 }
4973 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4974 skip |= LogError(
4975 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4976 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4977 }
4978 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4979 skip |= LogError(
4980 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4981 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4982 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004983 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
4984 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
4985 "vkCreateRayTracingPipelinesNV: flags must not include "
4986 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
4987 }
4988 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
4989 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
4990 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
4991 }
Peter Chen85366392019-05-14 15:20:11 -04004992 }
4993
4994 return skip;
4995}
4996
sourav parmarcd5fb182020-07-17 12:58:44 -07004997bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
4998 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
4999 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005000 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005001 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005002 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5003 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5004 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005005 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005006 for (uint32_t i = 0; i < createInfoCount; i++) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005007 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5008 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5009 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5010 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5011 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5012 }
5013 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5014 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5015 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5016 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
5017 }
5018 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005019 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005020 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
5021 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07005022 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
5023 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
5024 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005025 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
5026 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
5027 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005028 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005029 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005030 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5031 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5032 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5033 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07005034 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07005035 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5036 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5037 }
5038 }
sourav parmarf4a78252020-04-10 13:04:21 -07005039 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005040 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
5041 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07005042 }
5043 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005044 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07005045 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07005046 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
5047 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005048 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005049 }
5050 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5051 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
5052 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07005053 }
5054 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
5055 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
5056 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
5057 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
5058 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
5059 skip |= LogError(
5060 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07005061 "vkCreateRayTracingPipelinesKHR: If flags includes "
5062 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005063 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5064 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
5065 "must not be VK_SHADER_UNUSED_KHR");
5066 }
5067 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
5068 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
5069 skip |= LogError(
5070 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07005071 "vkCreateRayTracingPipelinesKHR: If flags includes "
5072 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005073 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5074 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
5075 "element must not be VK_SHADER_UNUSED_KHR");
5076 }
5077 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005078 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
5079 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
5080 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
5081 skip |= LogError(
5082 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
5083 "vkCreateRayTracingPipelinesKHR: If "
5084 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
5085 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
5086 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5087 }
5088 }
sourav parmarf4a78252020-04-10 13:04:21 -07005089 }
5090 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5091 if (pCreateInfos[i].basePipelineIndex != -1) {
5092 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5093 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07005094 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07005095 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5096 "and pCreateInfos->basePipelineIndex is not -1.");
5097 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005098 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005099 skip |=
5100 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
5101 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
5102 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
5103 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
5104 "element.");
5105 }
sourav parmarf4a78252020-04-10 13:04:21 -07005106 }
5107 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005108 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005109 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005110 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005111 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
5112 "commands pCreateInfos parameter %d.",
5113 pCreateInfos[i].basePipelineIndex, createInfoCount);
5114 }
5115 } else {
5116 if (pCreateInfos[i].basePipelineIndex != -1) {
5117 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07005118 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005119 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5120 }
5121 }
5122 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005123 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
5124 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
5125 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
5126 "vkCreateRayTracingPipelinesKHR: If flags includes "
5127 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
5128 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005129 }
5130 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
5131 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
5132 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
5133 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
5134 "pLibraryInfo and pLibraryInterface must be NULL.");
5135 }
5136 if (pCreateInfos[i].pLibraryInfo) {
5137 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
5138 if (pCreateInfos[i].stageCount == 0) {
5139 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
5140 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5141 "stageCount must not be 0.");
5142 }
5143 if (pCreateInfos[i].groupCount == 0) {
5144 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
5145 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5146 "groupCount must not be 0.");
5147 }
5148 } else {
5149 if (pCreateInfos[i].pLibraryInterface == NULL) {
5150 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
5151 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
5152 "is greater than 0, its "
5153 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005154 }
5155 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005156 }
5157 if (pCreateInfos[i].pLibraryInterface) {
5158 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
5159 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
5160 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
5161 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
5162 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
5163 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005164 }
5165 if (deferredOperation != VK_NULL_HANDLE) {
5166 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
5167 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
5168 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
5169 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07005170 }
5171 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005172 }
5173
5174 return skip;
5175}
5176
Mike Schuchardt21638df2019-03-16 10:52:02 -07005177#ifdef VK_USE_PLATFORM_WIN32_KHR
5178bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
5179 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005180 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07005181 bool skip = false;
5182 if (!device_extensions.vk_khr_swapchain)
5183 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
5184 if (!device_extensions.vk_khr_get_surface_capabilities_2)
5185 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
5186 if (!device_extensions.vk_khr_surface)
5187 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
5188 if (!device_extensions.vk_khr_get_physical_device_properties_2)
5189 skip |=
5190 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
5191 if (!device_extensions.vk_ext_full_screen_exclusive)
5192 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
5193 skip |= validate_struct_type(
5194 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
5195 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
5196 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
5197 if (pSurfaceInfo != NULL) {
5198 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
5199 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
5200 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
5201
5202 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
5203 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
5204 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5205 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005206 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5207 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005208
5209 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5210 }
5211 return skip;
5212}
5213#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005214
5215bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5216 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005217 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005218 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5219 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005220 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005221 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5222 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5223 }
5224 return skip;
5225}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005226
5227bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005228 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005229 bool skip = false;
5230
5231 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005232 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
5233 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005234 }
5235
5236 return skip;
5237}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005238
5239bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005240 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005241 bool skip = false;
5242
5243 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005244 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5245 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005246 }
5247
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005248 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005249 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005250 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5251 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005252 }
5253
5254 return skip;
5255}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005256
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005257bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5258 uint32_t bindingCount, const VkBuffer *pBuffers,
5259 const VkDeviceSize *pOffsets) const {
5260 bool skip = false;
5261 if (firstBinding > device_limits.maxVertexInputBindings) {
5262 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5263 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
5264 device_limits.maxVertexInputBindings);
5265 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5266 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
5267 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5268 "maxVertexInputBindings (%u)",
5269 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5270 }
5271
Jeff Bolz165818a2020-05-08 11:19:03 -05005272 for (uint32_t i = 0; i < bindingCount; ++i) {
5273 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005274 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005275 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5276 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5277 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5278 } else {
5279 if (pOffsets[i] != 0) {
5280 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5281 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5282 }
5283 }
5284 }
5285 }
5286
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005287 return skip;
5288}
5289
Mark Lobodzinski84988402019-09-11 15:27:30 -06005290bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005291 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005292 bool skip = false;
5293 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005294 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5295 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005296 }
5297 return skip;
5298}
5299
5300bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005301 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005302 bool skip = false;
5303 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005304 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5305 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005306 }
5307 return skip;
5308}
Petr Kraus3d720392019-11-13 02:52:39 +01005309
5310bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5311 VkSemaphore semaphore, VkFence fence,
5312 uint32_t *pImageIndex) const {
5313 bool skip = false;
5314
5315 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005316 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5317 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005318 }
5319
5320 return skip;
5321}
5322
5323bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5324 uint32_t *pImageIndex) const {
5325 bool skip = false;
5326
5327 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005328 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5329 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005330 }
5331
5332 return skip;
5333}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005334
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005335bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5336 uint32_t firstBinding, uint32_t bindingCount,
5337 const VkBuffer *pBuffers,
5338 const VkDeviceSize *pOffsets,
5339 const VkDeviceSize *pSizes) const {
5340 bool skip = false;
5341
5342 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5343 for (uint32_t i = 0; i < bindingCount; ++i) {
5344 if (pOffsets[i] & 3) {
5345 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5346 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5347 }
5348 }
5349
5350 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5351 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5352 "%s: The firstBinding(%" PRIu32
5353 ") index is greater than or equal to "
5354 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5355 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5356 }
5357
5358 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5359 skip |=
5360 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5361 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5362 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5363 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5364 }
5365
5366 for (uint32_t i = 0; i < bindingCount; ++i) {
5367 // pSizes is optional and may be nullptr.
5368 if (pSizes != nullptr) {
5369 if (pSizes[i] != VK_WHOLE_SIZE &&
5370 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5371 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5372 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5373 ") is not VK_WHOLE_SIZE and is greater than "
5374 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5375 cmd_name, i, pSizes[i]);
5376 }
5377 }
5378 }
5379
5380 return skip;
5381}
5382
5383bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5384 uint32_t firstCounterBuffer,
5385 uint32_t counterBufferCount,
5386 const VkBuffer *pCounterBuffers,
5387 const VkDeviceSize *pCounterBufferOffsets) const {
5388 bool skip = false;
5389
5390 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5391 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5392 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5393 "%s: The firstCounterBuffer(%" PRIu32
5394 ") index is greater than or equal to "
5395 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5396 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5397 }
5398
5399 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5400 skip |=
5401 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5402 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5403 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5404 cmd_name, firstCounterBuffer, counterBufferCount,
5405 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5406 }
5407
5408 return skip;
5409}
5410
5411bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5412 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5413 const VkBuffer *pCounterBuffers,
5414 const VkDeviceSize *pCounterBufferOffsets) const {
5415 bool skip = false;
5416
5417 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5418 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5419 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5420 "%s: The firstCounterBuffer(%" PRIu32
5421 ") index is greater than or equal to "
5422 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5423 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5424 }
5425
5426 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5427 skip |=
5428 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5429 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5430 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5431 cmd_name, firstCounterBuffer, counterBufferCount,
5432 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5433 }
5434
5435 return skip;
5436}
5437
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005438bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5439 uint32_t firstInstance, VkBuffer counterBuffer,
5440 VkDeviceSize counterBufferOffset,
5441 uint32_t counterOffset, uint32_t vertexStride) const {
5442 bool skip = false;
5443
5444 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005445 skip |= LogError(
5446 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005447 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5448 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5449 }
5450
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005451 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08005452 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005453 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu64 ") must be a multiple of 4.", counterOffset);
5454 }
5455
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005456 return skip;
5457}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005458
5459bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5460 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5461 const VkAllocationCallbacks *pAllocator,
5462 VkSamplerYcbcrConversion *pYcbcrConversion,
5463 const char *apiName) const {
5464 bool skip = false;
5465
5466 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005467 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005468 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005469 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005470 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5471 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005472 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005473 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005474 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005475
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005476#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005477 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005478 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005479#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005480 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005481#endif
5482
sfricke-samsung1a72f942020-07-25 12:09:18 -07005483 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005484
5485 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005486 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005487 const VkComponentMapping components = pCreateInfo->components;
5488 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5489 if (FormatIsXChromaSubsampled(format) == true) {
5490 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5491 skip |=
5492 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005493 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5494 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005495 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005496 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005497
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005498 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5499 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5500 skip |= LogError(
5501 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5502 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5503 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5504 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5505 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005506
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005507 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5508 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5509 skip |=
5510 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005511 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5512 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005513 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005514 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005515
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005516 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5517 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5518 skip |=
5519 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005520 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5521 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005522 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005523 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005524
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005525 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005526 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5527 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5528 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005529 skip |=
5530 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005531 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5532 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005533 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5534 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005535 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005536 }
5537
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005538 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5539 // Checks same VU multiple ways in order to give a more useful error message
5540 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5541 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5542 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5543 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5544 skip |= LogError(
5545 device, vuid,
5546 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5547 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5548 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5549 string_VkComponentSwizzle(components.b));
5550 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005551
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005552 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5553 // 4 channel format = no issue
5554 // 3 = no [a]
5555 // 2 = no [b,a]
5556 // 1 = no [g,b,a]
5557 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5558 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5559
5560 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5561 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5562 skip |= LogError(device, vuid,
5563 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5564 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5565 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5566 string_VkComponentSwizzle(components.b));
5567 } else if ((channels < 3) &&
5568 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5569 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5570 skip |= LogError(device, vuid,
5571 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5572 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5573 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5574 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5575 string_VkComponentSwizzle(components.b));
5576 } else if ((channels < 2) &&
5577 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5578 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5579 skip |= LogError(device, vuid,
5580 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5581 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5582 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5583 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5584 string_VkComponentSwizzle(components.b));
5585 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005586 }
5587 }
5588
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005589 return skip;
5590}
5591
5592bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5593 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5594 const VkAllocationCallbacks *pAllocator,
5595 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5596 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5597 "vkCreateSamplerYcbcrConversion");
5598}
5599
5600bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5601 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5602 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5603 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5604 "vkCreateSamplerYcbcrConversionKHR");
5605}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005606
5607bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5608 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5609 bool skip = false;
5610 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5611 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5612
5613 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005614 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5615 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5616 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5617 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5618 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005619 }
5620 return skip;
5621}
sourav parmara96ab1a2020-04-25 16:28:23 -07005622
5623bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005624 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005625 bool skip = false;
5626 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5627 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5628 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5629 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005630 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005631 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5632 skip |= LogError(
5633 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
5634 "vkCopyAccelerationStructureToMemoryKHR: The "
5635 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5636 }
5637 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
5638 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
5639 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
5640 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
5641 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
5642 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005643 return skip;
5644}
5645
5646bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5647 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5648 bool skip = false;
5649 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5650 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5651 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5652 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5653 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005654 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
5655 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
5656 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress must be aligned to 256 bytes.",
5657 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07005658 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005659 return skip;
5660}
5661
5662bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5663 const char *api_name) const {
5664 bool skip = false;
5665 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5666 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5667 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5668 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5669 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5670 api_name);
5671 }
5672 return skip;
5673}
5674
5675bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005676 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005677 bool skip = false;
5678 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005679 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005680 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07005681 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07005682 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
5683 "vkCopyAccelerationStructureKHR: The "
5684 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005685 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005686 return skip;
5687}
5688
5689bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5690 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5691 bool skip = false;
5692 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5693 return skip;
5694}
5695
5696bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005697 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005698 bool skip = false;
5699 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005700 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005701 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5702 }
5703 return skip;
5704}
5705
5706bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005707 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005708 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005709 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005710 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005711 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5712 skip |= LogError(
5713 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
5714 "vkCopyMemoryToAccelerationStructureKHR: The "
5715 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005716 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005717 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
5718 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07005719 return skip;
5720}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005721
sourav parmara96ab1a2020-04-25 16:28:23 -07005722bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5723 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5724 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005725 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07005726 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
5727 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
5728 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress must be aligned to 256 bytes.",
5729 pInfo->src.deviceAddress);
5730 }
sourav parmar83c31b12020-05-06 12:30:54 -07005731 return skip;
5732}
5733bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5734 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5735 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5736 bool skip = false;
5737 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5738 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5739 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5740 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5741 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5742 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5743 }
5744 return skip;
5745}
5746bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5747 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5748 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5749 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005750 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005751 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
5752 skip |= LogError(
5753 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
5754 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
5755 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5756 }
sourav parmar83c31b12020-05-06 12:30:54 -07005757 if (dataSize < accelerationStructureCount * stride) {
5758 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5759 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5760 "accelerationStructureCount (%d) *stride(%zu).",
5761 dataSize, accelerationStructureCount, stride);
5762 }
5763 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5764 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5765 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5766 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5767 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5768 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5769 }
5770 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5771 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5772 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5773 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5774 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5775 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5776 stride);
5777 }
5778 }
5779 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5780 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5781 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5782 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5783 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5784 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5785 stride);
5786 }
5787 }
sourav parmar83c31b12020-05-06 12:30:54 -07005788 return skip;
5789}
5790bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5791 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5792 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005793 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005794 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
5795 skip |= LogError(
5796 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
5797 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
5798 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07005799 }
5800 return skip;
5801}
5802
5803bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07005804 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
5805 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
5806 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
5807 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07005808 uint32_t width, uint32_t height, uint32_t depth) const {
5809 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005810 // RayGen
5811 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
5812 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
5813 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07005814 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005815 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5816 0) {
5817 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
5818 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
5819 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5820 }
5821 // Callable
5822 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5823 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
5824 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
5825 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005826 }
5827 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5828 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5829 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005830 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5831 }
5832 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5833 0) {
5834 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
5835 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
5836 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005837 }
5838 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005839 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5840 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
5841 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
5842 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005843 }
5844 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5845 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07005846 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
5847 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07005848 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005849 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5850 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
5851 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
5852 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5853 }
sourav parmar83c31b12020-05-06 12:30:54 -07005854 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005855 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5856 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
5857 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
5858 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07005859 }
5860 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5861 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5862 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005863 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5864 }
5865 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5866 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
5867 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
5868 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5869 }
5870 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
5871 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
5872 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
5873 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
5874 }
5875 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
5876 skip |=
5877 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
5878 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
5879 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07005880 }
5881
sourav parmarcd5fb182020-07-17 12:58:44 -07005882 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
5883 skip |=
5884 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
5885 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
5886 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
5887 }
5888
5889 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
5890 skip |=
5891 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
5892 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
5893 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07005894 }
5895 return skip;
5896}
5897
sourav parmarcd5fb182020-07-17 12:58:44 -07005898bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
5899 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
5900 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
5901 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07005902 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005903 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005904 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
5905 skip |= LogError(
5906 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
5907 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
5908 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005909 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005910 // RayGen
5911 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
5912 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
5913 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07005914 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005915 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5916 0) {
5917 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
5918 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
5919 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5920 }
5921 // Callabe
5922 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5923 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
5924 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
5925 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005926 }
5927 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5928 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07005929 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
5930 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5931 }
5932 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5933 0) {
5934 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
5935 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
5936 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005937 }
5938 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005939 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5940 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
5941 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
5942 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005943 }
5944 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5945 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07005946 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
5947 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07005948 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005949 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5950 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
5951 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
5952 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5953 }
sourav parmar83c31b12020-05-06 12:30:54 -07005954 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005955 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5956 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
5957 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
5958 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005959 }
5960 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5961 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07005962 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
5963 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5964 }
5965 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5966 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
5967 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
5968 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005969 }
5970
sourav parmarcd5fb182020-07-17 12:58:44 -07005971 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
5972 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
5973 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07005974 }
5975 return skip;
5976}
5977bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5978 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5979 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5980 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5981 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5982 uint32_t width, uint32_t height, uint32_t depth) const {
5983 bool skip = false;
5984 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5985 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5986 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5987 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5988 }
5989 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5990 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5991 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5992 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5993 }
5994 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5995 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5996 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5997 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5998 }
5999
6000 // hitShader
6001 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6002 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
6003 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
6004 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6005 }
6006 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6007 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
6008 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
6009 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6010 }
6011 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6012 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
6013 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
6014 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6015 }
6016
6017 // missShader
6018 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6019 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
6020 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
6021 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6022 }
6023 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6024 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
6025 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
6026 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6027 }
6028 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6029 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
6030 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
6031 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6032 }
6033
6034 // raygenShader
6035 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6036 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
6037 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07006038 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6039 }
6040 if (width > device_limits.maxComputeWorkGroupCount[0]) {
6041 skip |=
6042 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
6043 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
6044 }
6045 if (height > device_limits.maxComputeWorkGroupCount[1]) {
6046 skip |=
6047 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
6048 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
6049 }
6050 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
6051 skip |=
6052 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
6053 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07006054 }
6055 return skip;
6056}
6057
sourav parmar83c31b12020-05-06 12:30:54 -07006058bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006059 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
6060 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006061 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006062 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6063 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006064 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
6065 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006066 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07006067 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
6068 }
6069 return skip;
6070}
6071
Piers Daniell39842ee2020-07-10 16:42:33 -06006072bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
6073 const VkViewport *pViewports) const {
6074 bool skip = false;
6075
6076 if (!physical_device_features.multiViewport) {
6077 if (viewportCount != 1) {
6078 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
6079 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
6080 ") is not 1.",
6081 viewportCount);
6082 }
6083 } else { // multiViewport enabled
6084 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
6085 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
6086 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
6087 ") must "
6088 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6089 viewportCount, device_limits.maxViewports);
6090 }
6091 }
6092
6093 if (pViewports) {
6094 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
6095 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
6096 const char *fn_name = "vkCmdSetViewportWithCountEXT";
6097 skip |= manual_PreCallValidateViewport(
6098 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
6099 }
6100 }
6101
6102 return skip;
6103}
6104
6105bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
6106 const VkRect2D *pScissors) const {
6107 bool skip = false;
6108
6109 if (!physical_device_features.multiViewport) {
6110 if (scissorCount != 1) {
6111 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
6112 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6113 ") must "
6114 "be 1 when the multiViewport feature is disabled.",
6115 scissorCount);
6116 }
6117 } else { // multiViewport enabled
6118 if (scissorCount == 0) {
6119 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6120 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6121 ") must "
6122 "be great than zero.",
6123 scissorCount);
6124 } else if (scissorCount > device_limits.maxViewports) {
6125 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6126 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6127 ") must "
6128 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6129 scissorCount, device_limits.maxViewports);
6130 }
6131 }
6132
6133 if (pScissors) {
6134 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
6135 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
6136
6137 if (scissor.offset.x < 0) {
6138 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6139 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
6140 scissor.offset.x);
6141 }
6142
6143 if (scissor.offset.y < 0) {
6144 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6145 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
6146 scissor.offset.y);
6147 }
6148
6149 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
6150 if (x_sum > INT32_MAX) {
6151 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
6152 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6153 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6154 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
6155 }
6156
6157 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
6158 if (y_sum > INT32_MAX) {
6159 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
6160 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6161 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6162 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
6163 }
6164 }
6165 }
6166
6167 return skip;
6168}
6169
6170bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6171 uint32_t bindingCount, const VkBuffer *pBuffers,
6172 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
6173 const VkDeviceSize *pStrides) const {
6174 bool skip = false;
6175 if (firstBinding >= device_limits.maxVertexInputBindings) {
6176 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
6177 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
6178 firstBinding, device_limits.maxVertexInputBindings);
6179 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6180 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
6181 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
6182 "maxVertexInputBindings (%u)",
6183 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6184 }
6185
6186 for (uint32_t i = 0; i < bindingCount; ++i) {
6187 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006188 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06006189 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
6190 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
6191 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
6192 } else {
6193 if (pOffsets[i] != 0) {
6194 skip |=
6195 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
6196 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
6197 }
6198 }
6199 }
6200 if (pStrides) {
6201 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
6202 skip |=
6203 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
6204 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%u) must be less than maxVertexInputBindingStride (%u)", i,
6205 pStrides[i], device_limits.maxVertexInputBindingStride);
6206 }
6207 }
6208 }
6209
6210 return skip;
6211}
sourav parmarcd5fb182020-07-17 12:58:44 -07006212
6213bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6214 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6215 bool skip = false;
6216 for (uint32_t i = 0; i < infoCount; ++i) {
6217 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6218 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6219 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6220 }
6221 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6222 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6223 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6224 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6225 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6226 api_name);
6227 }
6228 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6229 skip |=
6230 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6231 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6232 }
6233 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6234 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6235 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6236 }
6237 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6238 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6239 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6240 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6241 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6242 api_name);
6243 }
6244 if (pInfos[i].pGeometries) {
6245 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6246 skip |= validate_ranged_enum(
6247 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6248 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6249 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6250 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006251 skip |= validate_struct_type(
6252 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6253 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6254 &(pInfos[i].pGeometries[j].geometry.triangles),
6255 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6256 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6257 skip |= validate_struct_pnext(
6258 api_name,
6259 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6260 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6261 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6262 skip |=
6263 validate_ranged_enum(api_name,
6264 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6265 ParameterName::IndexVector{i, j}),
6266 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6267 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6268 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6269 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6270 &pInfos[i].pGeometries[j].geometry.triangles,
6271 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6272 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6273 skip |= validate_ranged_enum(
6274 api_name,
6275 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6276 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6277 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6278
6279 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6280 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6281 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6282 }
6283 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6284 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6285 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6286 skip |=
6287 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6288 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6289 api_name);
6290 }
6291 }
6292 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6293 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6294 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6295 &pInfos[i].pGeometries[j].geometry.instances,
6296 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6297 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6298 skip |= validate_struct_type(
6299 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6300 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6301 &(pInfos[i].pGeometries[j].geometry.instances),
6302 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6303 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6304 skip |= validate_struct_pnext(
6305 api_name,
6306 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6307 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6308 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6309
6310 skip |= validate_bool32(api_name,
6311 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6312 ParameterName::IndexVector{i, j}),
6313 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6314 }
6315 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6316 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6317 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6318 &pInfos[i].pGeometries[j].geometry.aabbs,
6319 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6320 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6321 skip |= validate_struct_type(
6322 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6323 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6324 &(pInfos[i].pGeometries[j].geometry.aabbs),
6325 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6326 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6327 skip |= validate_struct_pnext(
6328 api_name,
6329 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6330 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6331 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6332 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6333 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6334 "(%s):stride must be less than or equal to 2^32-1", api_name);
6335 }
6336 }
6337 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6338 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6339 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6340 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6341 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6342 api_name);
6343 }
6344 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6345 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6346 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6347 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6348 "of elements of"
6349 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6350 api_name);
6351 }
6352 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6353 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6354 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6355 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6356 api_name);
6357 }
6358 }
6359 }
6360 }
6361 if (pInfos[i].ppGeometries != NULL) {
6362 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6363 skip |= validate_ranged_enum(
6364 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6365 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6366 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6367 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006368 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6369 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6370 &pInfos[i].ppGeometries[j]->geometry.triangles,
6371 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6372 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6373 skip |= validate_struct_type(
6374 api_name,
6375 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6376 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6377 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6378 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6379 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6380 skip |= validate_struct_pnext(
6381 api_name,
6382 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6383 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6384 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6385 skip |= validate_ranged_enum(api_name,
6386 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6387 ParameterName::IndexVector{i, j}),
6388 "VkFormat", AllVkFormatEnums,
6389 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6390 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6391 skip |= validate_ranged_enum(api_name,
6392 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6393 ParameterName::IndexVector{i, j}),
6394 "VkIndexType", AllVkIndexTypeEnums,
6395 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6396 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6397 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6398 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6399 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6400 }
6401 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6402 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6403 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6404 skip |=
6405 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6406 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6407 api_name);
6408 }
6409 }
6410 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6411 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6412 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6413 &pInfos[i].ppGeometries[j]->geometry.instances,
6414 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6415 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6416 skip |= validate_struct_type(
6417 api_name,
6418 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6419 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6420 &(pInfos[i].ppGeometries[j]->geometry.instances),
6421 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6422 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6423 skip |= validate_struct_pnext(
6424 api_name,
6425 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6426 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6427 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6428 skip |= validate_bool32(api_name,
6429 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6430 ParameterName::IndexVector{i, j}),
6431 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6432 }
6433 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6434 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6435 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6436 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6437 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6438 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6439 skip |= validate_struct_type(
6440 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6441 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6442 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6443 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6444 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6445 skip |= validate_struct_pnext(
6446 api_name,
6447 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6448 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6449 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6450 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6451 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6452 "(%s):stride must be less than or equal to 2^32-1", api_name);
6453 }
6454 }
6455 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6456 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6457 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6458 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6459 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6460 api_name);
6461 }
6462 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6463 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6464 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6465 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6466 "of elements of"
6467 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6468 api_name);
6469 }
6470 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6471 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6472 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6473 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6474 api_name);
6475 }
6476 }
6477 }
6478 }
6479 }
6480 return skip;
6481}
6482bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6483 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6484 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6485 bool skip = false;
6486 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6487 for (uint32_t i = 0; i < infoCount; ++i) {
6488 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6489 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6490 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6491 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6492 "scratchData.deviceAddress member must be a multiple of "
6493 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6494 }
6495 for (uint32_t k = 0; k < infoCount; ++k) {
6496 if (i == k) continue;
6497 bool found = false;
6498 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6499 skip |= LogError(
6500 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6501 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6502 "not be "
6503 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6504 i, k);
6505 found = true;
6506 }
6507 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6508 skip |= LogError(
6509 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
6510 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
6511 "not be "
6512 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6513 i, k);
6514 found = true;
6515 }
6516 if (found) break;
6517 }
6518 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6519 if (pInfos[i].pGeometries) {
6520 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6521 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6522 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6523 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6524 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6525 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6526 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6527 }
6528 } else {
6529 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6530 skip |=
6531 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6532 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6533 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6534 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6535 }
6536 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006537 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006538 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6539 skip |= LogError(
6540 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6541 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6542 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6543 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006544 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6545 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006546 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6547 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6548 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6549 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6550 }
6551 }
6552 } else if (pInfos[i].ppGeometries) {
6553 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6554 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6555 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6556 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6557 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6558 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6559 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6560 }
6561 } else {
6562 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6563 skip |=
6564 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6565 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6566 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6567 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6568 }
6569 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006570 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006571 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6572 skip |= LogError(
6573 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6574 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6575 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6576 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006577 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6578 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006579 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6580 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6581 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6582 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6583 }
6584 }
6585 }
6586 }
6587 }
6588 return skip;
6589}
6590
6591bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
6592 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6593 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
6594 const uint32_t *const *ppMaxPrimitiveCounts) const {
6595 bool skip = false;
6596 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
6597 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006598 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006599 if (!ray_tracing_acceleration_structure_features ||
6600 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
6601 skip |= LogError(
6602 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
6603 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
6604 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
6605 }
6606 for (uint32_t i = 0; i < infoCount; ++i) {
6607 if (pInfos[i].mode == VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR) {
6608 if (pInfos[i].srcAccelerationStructure == VK_NULL_HANDLE) {
6609 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03666",
6610 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, if its mode member is "
6611 "VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, its srcAccelerationStructure member must not be "
6612 "VK_NULL_HANDLE.");
6613 }
6614 }
6615 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6616 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6617 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
6618 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
6619 "scratchData.deviceAddress member must be a multiple of "
6620 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6621 }
6622 for (uint32_t k = 0; k < infoCount; ++k) {
6623 if (i == k) continue;
6624 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6625 skip |=
6626 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
6627 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
6628 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
6629 "any other element [%d) of pInfos.",
6630 i, k);
6631 break;
6632 }
6633 }
6634 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6635 if (pInfos[i].pGeometries) {
6636 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6637 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6638 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6639 skip |= LogError(
6640 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6641 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6642 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6643 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6644 }
6645 } else {
6646 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6647 skip |= LogError(
6648 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6649 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6650 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6651 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6652 }
6653 }
6654 }
6655 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6656 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6657 skip |= LogError(
6658 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6659 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6660 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6661 }
6662 }
6663 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6664 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
6665 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6666 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6667 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6668 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6669 }
6670 }
6671 } else if (pInfos[i].ppGeometries) {
6672 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6673 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6674 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6675 skip |= LogError(
6676 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6677 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6678 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6679 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6680 }
6681 } else {
6682 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6683 skip |= LogError(
6684 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6685 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6686 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6687 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6688 }
6689 }
6690 }
6691 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6692 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6693 skip |= LogError(
6694 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6695 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6696 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6697 }
6698 }
6699 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6700 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
6701 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6702 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6703 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6704 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6705 }
6706 }
6707 }
6708 }
6709 }
6710 return skip;
6711}
6712
6713bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
6714 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
6715 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6716 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6717 bool skip = false;
6718 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
6719 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006720 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006721 if (!ray_tracing_acceleration_structure_features ||
6722 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6723 skip |=
6724 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
6725 "vkBuildAccelerationStructuresKHR: The "
6726 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
6727 }
6728 for (uint32_t i = 0; i < infoCount; ++i) {
6729 for (uint32_t j = 0; j < infoCount; ++j) {
6730 if (i == j) continue;
6731 bool found = false;
6732 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6733 skip |= LogError(
6734 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6735 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
6736 "not be "
6737 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6738 i, j);
6739 found = true;
6740 }
6741 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6742 skip |= LogError(
6743 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
6744 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
6745 "not be "
6746 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6747 i, j);
6748 found = true;
6749 }
6750 if (found) break;
6751 }
6752 }
6753 return skip;
6754}
6755
6756bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
6757 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
6758 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
6759 bool skip = false;
6760 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
6761 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006762 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
6763 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006764 if (!(ray_tracing_pipeline_features || ray_query_features) ||
6765 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
6766 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
6767 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
6768 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
6769 }
6770 return skip;
6771}
sfricke-samsungecafb192021-01-17 08:21:14 -08006772
6773bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
6774 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
6775 const VkAllocationCallbacks *pAllocator,
6776 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
6777 bool skip = false;
6778 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
6779 if (private_data_features && private_data_features->privateData == VK_FALSE) {
6780 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
6781 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
6782 }
6783 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07006784}