blob: c7a2948a57863283186bfa9de2be37cadb914855 [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) {
sfricke-samsungad008902021-04-16 01:25:34 -07002901 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2902 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2903 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
2904 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002905 }
2906 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07002907 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
2908 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2909 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
2910 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002911 }
2912 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
2913 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsungad008902021-04-16 01:25:34 -07002914 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2915 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
2916 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002917 }
2918 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
2919 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsungad008902021-04-16 01:25:34 -07002920 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2921 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
2922 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002923 }
2924 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
2925 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsungad008902021-04-16 01:25:34 -07002926 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2927 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
2928 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002929 }
2930 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
2931 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsungad008902021-04-16 01:25:34 -07002932 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2933 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
2934 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002935 }
2936 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
2937 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsungad008902021-04-16 01:25:34 -07002938 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2939 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
2940 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002941 }
2942 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
2943 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsungad008902021-04-16 01:25:34 -07002944 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2945 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
2946 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002947 }
2948 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
2949 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsungad008902021-04-16 01:25:34 -07002950 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
2951 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
2952 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002953 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002954 }
2955 }
2956
2957 return skip;
2958}
2959
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002960bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2961 uint32_t createInfoCount,
2962 const VkComputePipelineCreateInfo *pCreateInfos,
2963 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002964 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002965 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002966 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002967 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002968 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002969 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002970 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04002971 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002972 skip |=
2973 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2974 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2975 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2976 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002977 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002978
2979 // Make sure compute stage is selected
2980 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002981 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2982 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2983 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002984 }
sourav parmarcd5fb182020-07-17 12:58:44 -07002985
2986 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
2987 skip |=
2988 LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
2989 "vkCreateComputePipelines(): flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR");
2990 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002991 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002992 return skip;
2993}
2994
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002995bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002996 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002997 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002998
2999 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003000 const auto &features = physical_device_features;
3001 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003002
John Zulauf71968502017-10-26 13:51:15 -06003003 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3004 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003005 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3006 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3007 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3008 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003009 }
3010
3011 // Anistropy cannot be enabled in sampler unless enabled as a feature
3012 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003013 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3014 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3015 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003016 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003017 }
John Zulauf71968502017-10-26 13:51:15 -06003018
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003019 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3020 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003021 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3022 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3023 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3024 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003025 }
3026 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003027 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3028 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3029 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3030 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003031 }
3032 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003033 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3034 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3035 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3036 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003037 }
3038 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3039 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3040 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3041 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003042 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3043 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3044 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3045 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3046 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3047 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003048 }
3049 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003050 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3051 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3052 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003053 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003054 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003055 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3056 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3057 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003058 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003059 }
3060
3061 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3062 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003063 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3064 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003065 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003066 if (sampler_reduction != nullptr) {
3067 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3068 skip |= LogError(
3069 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3070 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3071 }
3072 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003073 }
3074
3075 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3076 // valid VkBorderColor value
3077 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3078 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3079 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003080 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3081 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003082 }
3083
3084 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
3085 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003086 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003087 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
3088 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
3089 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06003090 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003091 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
3092 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
3093 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003094 }
John Zulauf275805c2017-10-26 15:34:49 -06003095
3096 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003097 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06003098 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3099 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003100 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3101 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3102 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003103 }
3104 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003105
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003106 // Check for valid Lod range
3107 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003108 skip |=
3109 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3110 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003111 }
3112
3113 // Check mipLodBias to device limit
3114 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003115 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3116 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3117 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003118 }
3119
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003120 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003121 if (sampler_conversion != nullptr) {
3122 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3123 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3124 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3125 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003126 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003127 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003128 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3129 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3130 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3131 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3132 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3133 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3134 }
3135 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003136
3137 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3138 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3139 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3140 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3141 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3142 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3143 }
3144 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3145 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3146 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3147 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3148 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3149 }
3150 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3151 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3152 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3153 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3154 pCreateInfo->minLod, pCreateInfo->maxLod);
3155 }
3156 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3157 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3158 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3159 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3160 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3161 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3162 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3163 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3164 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3165 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3166 }
3167 if (pCreateInfo->anisotropyEnable) {
3168 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3169 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3170 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3171 }
3172 if (pCreateInfo->compareEnable) {
3173 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3174 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3175 "pCreateInfo->compareEnable must be VK_FALSE");
3176 }
3177 if (pCreateInfo->unnormalizedCoordinates) {
3178 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3179 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3180 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3181 }
3182 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003183 }
3184
Tony-LunarG7337b312020-04-15 16:40:25 -06003185 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3186 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3187 if (!device_extensions.vk_ext_custom_border_color) {
3188 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3189 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3190 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3191 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003192 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003193 if (!custom_create_info) {
3194 skip |=
3195 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3196 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3197 "struct in pNext chain.\n",
3198 string_VkBorderColor(pCreateInfo->borderColor));
3199 } else {
3200 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3201 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3202 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3203 !FormatIsSampledFloat(custom_create_info->format)))) {
3204 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3205 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3206 "whose type does not match\n",
3207 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3208 ;
3209 }
3210 }
3211 }
3212
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003213 return skip;
3214}
3215
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003216bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3217 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3218 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003219 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003220 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003221
3222 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3223 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3224 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3225 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003226 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3227 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3228 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3229 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3230 ++descriptor_index) {
3231 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003232 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003233 "vkCreateDescriptorSetLayout: required parameter "
3234 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3235 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003236 }
3237 }
3238 }
3239
3240 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3241 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3242 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003243 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3244 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3245 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3246 "values.",
3247 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003248 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003249
3250 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3251 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3252 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3253 skip |=
3254 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3255 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3256 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3257 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3258 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3259 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003260 }
3261 }
3262 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003263 return skip;
3264}
3265
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003266bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3267 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003268 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003269 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3270 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3271 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003272 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3273 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003274}
3275
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003276bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3277 const VkWriteDescriptorSet *pDescriptorWrites,
3278 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003279 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003280
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003281 if (pDescriptorWrites != NULL) {
3282 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3283 // descriptorCount must be greater than 0
3284 if (pDescriptorWrites[i].descriptorCount == 0) {
3285 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003286 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3287 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003288 }
3289
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003290 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3291 if (validateDstSet) {
3292 // dstSet must be a valid VkDescriptorSet handle
3293 skip |= validate_required_handle(vkCallingFunction,
3294 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3295 pDescriptorWrites[i].dstSet);
3296 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003297
3298 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3299 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3300 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3301 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3302 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3303 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3304 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003305 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3306 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003307 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003308 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3309 "%s(): if pDescriptorWrites[%d].descriptorType is "
3310 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3311 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3312 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3313 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003314 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3315 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003316 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3317 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003318 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3319 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003320 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003321 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3322 ParameterName::IndexVector{i, descriptor_index}),
3323 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003324 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003325 }
3326 }
3327 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3328 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3329 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3330 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3331 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3332 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3333 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003334 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003335 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003336 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3337 "%s(): if pDescriptorWrites[%d].descriptorType is "
3338 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3339 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3340 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3341 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003342 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003343 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003344 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003345 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003346 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3347 ++descriptor_index) {
3348 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3349 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3350 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003351 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3352 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003353 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003354 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3355 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003356 }
3357 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003358 }
3359 }
3360 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3361 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003362 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003363 }
3364
3365 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3366 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003367 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003368 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3369 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003370 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003371 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003372 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3373 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3374 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003375 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003376 }
3377 }
3378 }
3379 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3380 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003381 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003382 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3383 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003384 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003385 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003386 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3387 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3388 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003389 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003390 }
3391 }
3392 }
3393 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003394 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3395 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003396 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003397 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003398 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3399 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3400 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3401 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3402 "accelerationStructureCount %d member equals descriptorCount %d.",
3403 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3404 pDescriptorWrites[i].descriptorCount);
3405 }
3406 // further checks only if we have right structtype
3407 if (pnext_struct) {
3408 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3409 skip |= LogError(
3410 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3411 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3412 ".",
3413 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003414 }
sourav parmarbcee7512020-12-28 14:34:49 -08003415 if (pnext_struct->accelerationStructureCount == 0) {
3416 skip |= LogError(device,
3417 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
3418 "%s(): accelerationStructureCount must be greater than 0 .");
3419 }
3420 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003421 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003422 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3423 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3424 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3425 skip |= LogError(device,
3426 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3427 "%s(): If the nullDescriptor feature is not enabled, each member of "
3428 "pAccelerationStructures must not be VK_NULL_HANDLE.");
sourav parmarcd5fb182020-07-17 12:58:44 -07003429 }
3430 }
3431 }
sourav parmarbcee7512020-12-28 14:34:49 -08003432 }
3433 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003434 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003435 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3436 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3437 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3438 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3439 "accelerationStructureCount %d member equals descriptorCount %d.",
3440 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3441 pDescriptorWrites[i].descriptorCount);
3442 }
3443 // further checks only if we have right structtype
3444 if (pnext_struct) {
3445 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3446 skip |= LogError(
3447 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3448 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3449 ".",
3450 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003451 }
sourav parmarbcee7512020-12-28 14:34:49 -08003452 if (pnext_struct->accelerationStructureCount == 0) {
3453 skip |= LogError(device,
3454 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
3455 "%s(): accelerationStructureCount must be greater than 0 .");
3456 }
3457 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003458 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003459 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3460 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3461 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3462 skip |= LogError(device,
3463 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3464 "%s(): If the nullDescriptor feature is not enabled, each member of "
3465 "pAccelerationStructures must not be VK_NULL_HANDLE.");
sourav parmarcd5fb182020-07-17 12:58:44 -07003466 }
3467 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003468 }
3469 }
3470 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003471 }
3472 }
3473 return skip;
3474}
3475
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003476bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3477 const VkWriteDescriptorSet *pDescriptorWrites,
3478 uint32_t descriptorCopyCount,
3479 const VkCopyDescriptorSet *pDescriptorCopies) const {
3480 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3481}
3482
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003483bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003484 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003485 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003486 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3487}
3488
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003489bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3490 const VkAllocationCallbacks *pAllocator,
3491 VkRenderPass *pRenderPass) const {
3492 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3493}
3494
Mike Schuchardt2df08912020-12-15 16:28:09 -08003495bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003496 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003497 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003498 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3499}
3500
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003501bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3502 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003503 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003504 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003505
3506 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3507 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3508 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003509 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3510 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003511 return skip;
3512}
3513
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003514bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003515 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003516 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003517
3518 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3519 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003520 bool cb_is_secondary;
3521 {
3522 auto lock = cb_read_lock();
3523 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3524 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003525
Tony-LunarG3c287f62020-12-17 12:39:49 -07003526 if (cb_is_secondary) {
3527 // Implicit VUs
3528 // validate only sType here; pointer has to be validated in core_validation
3529 const bool k_not_required = false;
3530 const char *k_no_vuid = nullptr;
3531 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3532 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003533 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3534 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003535
Tony-LunarG3c287f62020-12-17 12:39:49 -07003536 if (info) {
3537 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003538 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003539 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003540 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3541 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3542 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3543 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003544
Tony-LunarG3c287f62020-12-17 12:39:49 -07003545 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003546
Tony-LunarG3c287f62020-12-17 12:39:49 -07003547 // Explicit VUs
3548 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003549 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003550 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3551 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3552 cmd_name);
3553 }
3554
3555 if (physical_device_features.inheritedQueries) {
3556 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003557 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3558 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3559 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003560 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003561 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003562 }
3563
3564 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003565 skip |=
3566 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
3567 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
3568 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
3569 } else { // !pipelineStatisticsQuery
3570 skip |=
3571 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
3572 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003573 }
3574
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003575 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003576 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003577 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003578 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3579 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
3580 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003581 commandBuffer,
3582 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07003583 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3584 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3585 }
Petr Kraus139757b2019-08-15 17:19:33 +02003586 }
3587 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003588 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003589 return skip;
3590}
3591
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003592bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003593 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003594 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003595
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003596 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003597 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003598 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3599 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3600 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003601 }
3602 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003603 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3604 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3605 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003606 }
3607 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003608 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003609 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003610 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3611 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3612 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3613 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003614 }
3615 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003616
3617 if (pViewports) {
3618 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3619 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003620 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003621 skip |= manual_PreCallValidateViewport(
3622 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003623 }
3624 }
3625
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003626 return skip;
3627}
3628
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003629bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003630 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003631 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003632
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003633 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003634 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003635 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3636 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3637 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003638 }
3639 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003640 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3641 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3642 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003643 }
3644 } else { // multiViewport enabled
3645 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003646 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003647 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3648 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3649 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3650 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003651 }
3652 }
3653
Petr Kraus6260f0a2018-02-27 21:15:55 +01003654 if (pScissors) {
3655 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3656 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003657
Petr Kraus6260f0a2018-02-27 21:15:55 +01003658 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003659 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3660 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3661 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003662 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003663
Petr Kraus6260f0a2018-02-27 21:15:55 +01003664 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003665 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3666 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3667 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003668 }
3669
3670 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3671 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003672 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3673 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3674 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3675 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003676 }
3677
3678 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3679 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003680 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3681 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3682 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3683 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003684 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003685 }
3686 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003687
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003688 return skip;
3689}
3690
Jeff Bolz5c801d12019-10-09 10:38:45 -05003691bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003692 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003693
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003694 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003695 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3696 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003697 }
3698
3699 return skip;
3700}
3701
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003702bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003703 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003704 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003705
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003706 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003707 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003708 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
3709 }
3710 if (drawCount > device_limits.maxDrawIndirectCount) {
3711 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003712 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
3713 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003714 }
3715 return skip;
3716}
3717
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003718bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003719 VkDeviceSize offset, uint32_t drawCount,
3720 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003721 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003722 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003723 skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
3724 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
3725 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003726 }
3727 if (drawCount > device_limits.maxDrawIndirectCount) {
3728 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003729 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).",
3730 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003731 }
3732 return skip;
3733}
3734
sfricke-samsungf692b972020-05-02 08:00:45 -07003735bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3736 VkDeviceSize countBufferOffset, bool khr) const {
3737 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003738 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003739 if (offset & 3) {
3740 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003741 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003742 }
3743
3744 if (countBufferOffset & 3) {
3745 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003746 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003747 countBufferOffset);
3748 }
3749 return skip;
3750}
3751
3752bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3753 VkDeviceSize offset, VkBuffer countBuffer,
3754 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3755 uint32_t stride) const {
3756 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3757}
3758
3759bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3760 VkDeviceSize offset, VkBuffer countBuffer,
3761 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3762 uint32_t stride) const {
3763 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3764}
3765
3766bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3767 VkDeviceSize countBufferOffset, bool khr) const {
3768 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003769 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003770 if (offset & 3) {
3771 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003772 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003773 }
3774
3775 if (countBufferOffset & 3) {
3776 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003777 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003778 countBufferOffset);
3779 }
3780 return skip;
3781}
3782
3783bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3784 VkDeviceSize offset, VkBuffer countBuffer,
3785 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3786 uint32_t stride) const {
3787 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3788}
3789
3790bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3791 VkDeviceSize offset, VkBuffer countBuffer,
3792 VkDeviceSize countBufferOffset,
3793 uint32_t maxDrawCount, uint32_t stride) const {
3794 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3795}
3796
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003797bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3798 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003799 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003800 bool skip = false;
3801 for (uint32_t rect = 0; rect < rectCount; rect++) {
3802 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003803 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3804 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003805 }
sfricke-samsung10867682020-04-25 02:20:39 -07003806 if (pRects[rect].rect.extent.width == 0) {
3807 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3808 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3809 }
3810 if (pRects[rect].rect.extent.height == 0) {
3811 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3812 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3813 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003814 }
3815 return skip;
3816}
3817
Andrew Fobel3abeb992020-01-20 16:33:22 -05003818bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3819 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3820 VkImageFormatProperties2 *pImageFormatProperties,
3821 const char *apiName) const {
3822 bool skip = false;
3823
3824 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003825 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003826 if (image_stencil_struct != nullptr) {
3827 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3828 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3829 // No flags other than the legal attachment bits may be set
3830 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3831 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003832 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3833 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3834 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3835 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3836 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003837 }
3838 }
3839 }
3840 }
3841
3842 return skip;
3843}
3844
3845bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3846 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3847 VkImageFormatProperties2 *pImageFormatProperties) const {
3848 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3849 "vkGetPhysicalDeviceImageFormatProperties2");
3850}
3851
3852bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3853 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3854 VkImageFormatProperties2 *pImageFormatProperties) const {
3855 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3856 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3857}
3858
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03003859bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
3860 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
3861 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
3862 bool skip = false;
3863
3864 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
3865 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
3866 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
3867 }
3868
3869 return skip;
3870}
3871
sfricke-samsung3999ef62020-02-09 17:05:59 -08003872bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3873 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3874 bool skip = false;
3875
3876 if (pRegions != nullptr) {
3877 for (uint32_t i = 0; i < regionCount; i++) {
3878 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003879 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3880 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003881 }
3882 }
3883 }
3884 return skip;
3885}
3886
Jeff Leger178b1e52020-10-05 12:22:23 -04003887bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
3888 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
3889 bool skip = false;
3890
3891 if (pCopyBufferInfo->pRegions != nullptr) {
3892 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
3893 if (pCopyBufferInfo->pRegions[i].size == 0) {
3894 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
3895 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
3896 }
3897 }
3898 }
3899 return skip;
3900}
3901
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003902bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003903 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3904 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003905 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003906
3907 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003908 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3909 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3910 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003911 }
3912
3913 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003914 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3915 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3916 "), must be greater than zero and less than or equal to 65536.",
3917 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003918 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003919 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3920 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3921 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003922 }
3923 return skip;
3924}
3925
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003926bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003927 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003928 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003929
3930 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003931 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3932 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3933 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003934 }
3935
3936 if (size != VK_WHOLE_SIZE) {
3937 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003938 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003939 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3940 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003941 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003942 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3943 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003944 }
3945 }
3946 return skip;
3947}
3948
sfricke-samsunga1d00272021-03-10 21:37:41 -08003949bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003950 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003951
3952 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003953 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3954 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3955 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3956 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003957 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08003958 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3959 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
3960 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003961 }
3962
3963 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3964 // queueFamilyIndexCount uint32_t values
3965 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003966 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08003967 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003968 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08003969 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
3970 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003971 }
3972 }
3973
Dave Houlton413a6782018-05-22 13:01:54 -06003974 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08003975 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003976
sfricke-samsunga1d00272021-03-10 21:37:41 -08003977 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
3978 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
3979 if (format_list_info) {
3980 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
3981 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
3982 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
3983 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
3984 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1 if it is in the pNext chain.",
3985 func_name, viewFormatCount);
3986 }
3987
3988 // Using the first format, compare the rest of the formats against it that they are compatible
3989 for (uint32_t i = 1; i < viewFormatCount; i++) {
3990 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
3991 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
3992 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
3993 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
3994 "VkImageFormatListCreateInfo::pViewFormats[%u] (%s) are not compatible in the pNext chain.",
3995 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
3996 string_VkFormat(format_list_info->pViewFormats[i]));
3997 }
3998 }
3999 }
4000
4001 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4002 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4003 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4004 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4005 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4006 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4007 func_name);
4008 } else {
4009 if (format_list_info == nullptr) {
4010 skip |= LogError(
4011 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4012 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4013 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4014 func_name);
4015 } else if (format_list_info->viewFormatCount == 0) {
4016 skip |= LogError(
4017 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4018 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4019 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4020 func_name);
4021 } else {
4022 bool found_base_format = false;
4023 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4024 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4025 found_base_format = true;
4026 break;
4027 }
4028 }
4029 if (!found_base_format) {
4030 skip |=
4031 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4032 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4033 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4034 "pCreateInfo->imageFormat.",
4035 func_name);
4036 }
4037 }
4038 }
4039 }
4040 }
4041 return skip;
4042}
4043
4044bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4045 const VkAllocationCallbacks *pAllocator,
4046 VkSwapchainKHR *pSwapchain) const {
4047 bool skip = false;
4048 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4049 return skip;
4050}
4051
4052bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4053 const VkSwapchainCreateInfoKHR *pCreateInfos,
4054 const VkAllocationCallbacks *pAllocator,
4055 VkSwapchainKHR *pSwapchains) const {
4056 bool skip = false;
4057 if (pCreateInfos) {
4058 for (uint32_t i = 0; i < swapchainCount; i++) {
4059 std::stringstream func_name;
4060 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4061 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4062 }
4063 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004064 return skip;
4065}
4066
Jeff Bolz5c801d12019-10-09 10:38:45 -05004067bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004068 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004069
4070 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004071 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004072 if (present_regions) {
4073 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004074 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004075 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4076 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004077 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004078 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4079 "extension swapchainCount is %i. These values must be equal.",
4080 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004081 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004082 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004083 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4084 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004085 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4086 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4087 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004088 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004089 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004090 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004091 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004092 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004093 }
4094 }
4095
4096 return skip;
4097}
4098
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004099bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4100 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4101 const VkAllocationCallbacks *pAllocator,
4102 VkDisplayModeKHR *pMode) const {
4103 bool skip = false;
4104
4105 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4106 if (display_mode_parameters.visibleRegion.width == 0) {
4107 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4108 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4109 }
4110 if (display_mode_parameters.visibleRegion.height == 0) {
4111 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4112 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4113 }
4114 if (display_mode_parameters.refreshRate == 0) {
4115 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4116 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4117 }
4118
4119 return skip;
4120}
4121
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004122#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004123bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4124 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4125 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004126 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004127 bool skip = false;
4128
4129 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004130 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4131 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004132 }
4133
4134 return skip;
4135}
4136#endif // VK_USE_PLATFORM_WIN32_KHR
4137
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004138bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004139 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004140 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004141 bool skip = false;
4142
4143 if (pCreateInfo) {
4144 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004145 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4146 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004147 }
4148
4149 if (pCreateInfo->pPoolSizes) {
4150 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4151 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004152 skip |= LogError(
4153 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004154 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004155 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004156 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4157 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004158 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4159 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4160 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4161 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4162 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004163 }
Petr Krausc8655be2017-09-27 18:56:51 +02004164 }
4165 }
4166 }
4167
4168 return skip;
4169}
4170
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004171bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004172 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004173 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004174
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004175 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004176 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004177 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4178 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4179 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004180 }
4181
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004182 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004183 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004184 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4185 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4186 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004187 }
4188
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004189 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004190 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004191 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4192 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4193 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004194 }
4195
4196 return skip;
4197}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004198
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004199bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004200 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004201 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004202
4203 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004204 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
4205 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07004206 }
4207 return skip;
4208}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004209
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004210bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4211 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004212 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004213 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004214
4215 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004216 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004217 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004218 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4219 "vkCmdDispatch(): baseGroupX (%" PRIu32
4220 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4221 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004222 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004223 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4224 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4225 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4226 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004227 }
4228
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004229 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004230 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004231 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4232 "vkCmdDispatch(): baseGroupY (%" PRIu32
4233 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4234 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004235 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004236 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4237 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4238 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4239 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004240 }
4241
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004242 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004243 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004244 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4245 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4246 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4247 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004248 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004249 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4250 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4251 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4252 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004253 }
4254
4255 return skip;
4256}
4257
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004258bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4259 VkPipelineBindPoint pipelineBindPoint,
4260 VkPipelineLayout layout, uint32_t set,
4261 uint32_t descriptorWriteCount,
4262 const VkWriteDescriptorSet *pDescriptorWrites) const {
4263 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4264}
4265
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004266bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4267 uint32_t firstExclusiveScissor,
4268 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004269 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004270 bool skip = false;
4271
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004272 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004273 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004274 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004275 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4276 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4277 ") is not 0.",
4278 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004279 }
4280 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004281 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004282 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4283 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4284 ") is not 1.",
4285 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004286 }
4287 } else { // multiViewport enabled
4288 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004289 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004290 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4291 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4292 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4293 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004294 }
4295 }
4296
Jeff Bolz3e71f782018-08-29 23:15:45 -05004297 if (pExclusiveScissors) {
4298 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4299 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4300
4301 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004302 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4303 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4304 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004305 }
4306
4307 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004308 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4309 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4310 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004311 }
4312
4313 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4314 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004315 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4316 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4317 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4318 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004319 }
4320
4321 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4322 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004323 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4324 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4325 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4326 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004327 }
4328 }
4329 }
4330
4331 return skip;
4332}
4333
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004334bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4335 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004336 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004337 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004338 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4339 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4340 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4341 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4342 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4343 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004344 }
4345
4346 return skip;
4347}
4348
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004349bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4350 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004351 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004352 bool skip = false;
4353
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004354 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004355 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004356 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004357 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4358 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4359 ") is not 0.",
4360 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004361 }
4362 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004363 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004364 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4365 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4366 ") is not 1.",
4367 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004368 }
4369 }
4370
Jeff Bolz9af91c52018-09-01 21:53:57 -05004371 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004372 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004373 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4374 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4375 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4376 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004377 }
4378
4379 return skip;
4380}
4381
Jeff Bolz5c801d12019-10-09 10:38:45 -05004382bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4383 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4384 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004385 bool skip = false;
4386
Dave Houlton142c4cb2018-10-17 15:04:41 -06004387 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004388 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4389 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4390 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004391 }
4392
4393 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004394 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004395 }
4396
4397 return skip;
4398}
4399
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004400bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004401 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004402 bool skip = false;
4403
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004404 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004405 skip |= LogError(
4406 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004407 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4408 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004409 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004410 }
4411
4412 return skip;
4413}
4414
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004415bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4416 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004417 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004418 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004419 static const int condition_multiples = 0b0011;
4420 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004421 skip |= LogError(
4422 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004423 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004424 }
Lockee1c22882019-06-10 16:02:54 -06004425 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004426 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4427 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4428 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4429 stride);
Lockee1c22882019-06-10 16:02:54 -06004430 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004431 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004432 skip |= LogError(
4433 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4434 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004435 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004436 if (drawCount > device_limits.maxDrawIndirectCount) {
4437 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004438 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4439 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004440 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004441 return skip;
4442}
4443
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004444bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4445 VkDeviceSize offset, VkBuffer countBuffer,
4446 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004447 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004448 bool skip = false;
4449
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004450 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004451 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4452 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4453 "), is not a multiple of 4.",
4454 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004455 }
4456
4457 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004458 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4459 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4460 "), is not a multiple of 4.",
4461 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004462 }
4463
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004464 return skip;
4465}
4466
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004467bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004468 const VkAllocationCallbacks *pAllocator,
4469 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004470 bool skip = false;
4471
4472 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4473 if (pCreateInfo != nullptr) {
4474 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4475 // VkQueryPipelineStatisticFlagBits values
4476 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4477 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004478 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4479 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4480 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4481 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004482 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004483 if (pCreateInfo->queryCount == 0) {
4484 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4485 "vkCreateQueryPool(): queryCount must be greater than zero.");
4486 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004487 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004488 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004489}
4490
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004491bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4492 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004493 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004494 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4495 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004496}
4497
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004498void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004499 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4500 VkResult result) {
4501 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004502 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004503}
4504
Mike Schuchardt2df08912020-12-15 16:28:09 -08004505void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004506 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4507 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004508 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004509 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004510 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004511}
4512
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004513void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4514 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004515 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004516 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004517 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004518}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004519
Tony-LunarG3c287f62020-12-17 12:39:49 -07004520void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004521 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004522 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
4523 auto lock = cb_write_lock();
4524 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06004525 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004526 }
4527 }
4528}
4529
4530void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004531 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004532 auto lock = cb_write_lock();
4533 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
4534 secondary_cb_map.erase(pCommandBuffers[cb_index]);
4535 }
4536}
4537
4538void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004539 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004540 auto lock = cb_write_lock();
4541 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
4542 if (item->second == commandPool) {
4543 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004544 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004545 ++item;
4546 }
4547 }
4548}
4549
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004550bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004551 const VkAllocationCallbacks *pAllocator,
4552 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004553 bool skip = false;
4554
4555 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004556 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004557 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004558 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4559 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004560 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004561
4562 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004563 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004564 if (flags_info) {
4565 flags = flags_info->flags;
4566 }
4567
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004568 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004569 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08004570 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004571 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4572 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08004573 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004574 }
4575
4576#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004577 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004578#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004579 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4580 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004581#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004582 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004583#endif
4584
4585 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004586 skip |= LogError(
4587 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004588 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4589 }
4590 if (
4591#ifdef VK_USE_PLATFORM_WIN32_KHR
4592 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4593#endif
4594 (import_memory_fd && import_memory_fd->handleType) ||
4595#ifdef VK_USE_PLATFORM_ANDROID_KHR
4596 (import_memory_ahb && import_memory_ahb->buffer) ||
4597#endif
4598 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004599 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4600 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004601 }
4602 }
4603
4604 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004605 VkBool32 capture_replay = false;
4606 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004607 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004608 if (vulkan_12_features) {
4609 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4610 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4611 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004612 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004613 if (bda_features) {
4614 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4615 buffer_device_address = bda_features->bufferDeviceAddress;
4616 }
4617 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004618 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004619 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004620 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004621 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004622 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004623 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004624 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004625 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004626 }
4627 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004628 }
4629 return skip;
4630}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004631
Jason Macnak192fa0e2019-07-26 15:07:16 -07004632bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004633 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004634 bool skip = false;
4635
4636 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4637 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4638 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004639 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004640 } else {
4641 uint32_t vertex_component_size = 0;
4642 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4643 vertex_component_size = 4;
4644 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4645 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4646 vertex_component_size = 2;
4647 }
4648 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004649 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004650 }
4651 }
4652
4653 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4654 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004655 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004656 } else {
4657 uint32_t index_element_size = 0;
4658 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4659 index_element_size = 4;
4660 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4661 index_element_size = 2;
4662 }
4663 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004664 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004665 }
4666 }
4667 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4668 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004669 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004670 }
4671 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004672 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004673 }
4674 }
4675
4676 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004677 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004678 }
4679
4680 return skip;
4681}
4682
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004683bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4684 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004685 bool skip = false;
4686
4687 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004688 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004689 }
4690 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004691 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004692 }
4693
4694 return skip;
4695}
4696
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004697bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4698 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004699 bool skip = false;
4700 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004701 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004702 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004703 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004704 }
4705 return skip;
4706}
4707
4708bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004709 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004710 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004711 bool skip = false;
4712 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004713 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4714 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4715 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004716 }
4717 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004718 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4719 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4720 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004721 }
4722 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4723 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004724 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4725 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4726 "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 -07004727 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004728 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004729 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004730 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4731 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004732 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4733 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004734 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004735 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004736 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4737 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4738 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004739 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004740 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004741 uint64_t total_triangle_count = 0;
4742 for (uint32_t i = 0; i < info.geometryCount; i++) {
4743 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004744
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004745 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004746
Jason Macnak5c954952019-07-09 15:46:12 -07004747 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4748 continue;
4749 }
4750 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4751 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004752 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004753 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4754 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4755 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004756 }
4757 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004758 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4759 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4760 for (uint32_t i = 1; i < info.geometryCount; i++) {
4761 const VkGeometryNV &geometry = info.pGeometries[i];
4762 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004763 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004764 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4765 "info.pGeometries[0].geometryType.",
4766 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004767 }
4768 }
4769 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004770 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4771 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4772 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4773 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4774 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4775 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4776 }
4777 }
4778 skip |=
4779 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004780 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004781 return skip;
4782}
4783
Ricardo Garciaa4935972019-02-21 17:43:18 +01004784bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4785 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004786 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004787 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004788 if (pCreateInfo) {
4789 if ((pCreateInfo->compactedSize != 0) &&
4790 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004791 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4792 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4793 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4794 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004795 }
Jason Macnak5c954952019-07-09 15:46:12 -07004796
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004797 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004798 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004799 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004800 return skip;
4801}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004802
Jeff Bolz5c801d12019-10-09 10:38:45 -05004803bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4804 const VkAccelerationStructureInfoNV *pInfo,
4805 VkBuffer instanceData, VkDeviceSize instanceOffset,
4806 VkBool32 update, VkAccelerationStructureNV dst,
4807 VkAccelerationStructureNV src, VkBuffer scratch,
4808 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004809 bool skip = false;
4810
4811 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004812 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004813 }
4814
4815 return skip;
4816}
4817
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004818bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4819 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4820 VkAccelerationStructureKHR *pAccelerationStructure) const {
4821 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07004822 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004823 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07004824 if (!acceleration_structure_features ||
4825 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
4826 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
4827 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
4828 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004829 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004830 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
4831 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004832 (acceleration_structure_features &&
4833 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07004834 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07004835 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
4836 "vkCreateAccelerationStructureKHR(): If createFlags includes "
4837 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
4838 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07004839 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004840 if (pCreateInfo->deviceAddress &&
4841 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
4842 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
4843 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
4844 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
4845 }
4846 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
4847 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
4848 "vkCreateAccelerationStructureKHR(): offset must be a multiple of 256 bytes", pCreateInfo->offset);
4849 }
sourav parmar83c31b12020-05-06 12:30:54 -07004850 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004851 return skip;
4852}
4853
Jason Macnak5c954952019-07-09 15:46:12 -07004854bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4855 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004856 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004857 bool skip = false;
4858 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004859 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4860 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004861 }
4862 return skip;
4863}
4864
sourav parmarcd5fb182020-07-17 12:58:44 -07004865bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
4866 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
4867 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
4868 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07004869 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004870 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-03432",
4871 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07004872 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07004873 }
4874 return skip;
4875}
4876
Peter Chen85366392019-05-14 15:20:11 -04004877bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4878 uint32_t createInfoCount,
4879 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4880 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004881 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004882 bool skip = false;
4883
4884 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004885 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04004886 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004887 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004888 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4889 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4890 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4891 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004892 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004893
4894 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004895 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07004896 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4897 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4898 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4899 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4900 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4901 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4902 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4903 }
4904 }
4905
sourav parmarf4a78252020-04-10 13:04:21 -07004906 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4907 skip |=
4908 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4909 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4910 }
4911 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4912 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4913 skip |=
4914 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4915 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4916 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4917 }
4918 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4919 if (pCreateInfos[i].basePipelineIndex != -1) {
4920 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4921 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4922 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4923 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4924 "and pCreateInfos->basePipelineIndex is not -1.");
4925 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004926 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004927 skip |=
4928 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
4929 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
4930 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
4931 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
4932 "that element.");
4933 }
sourav parmarf4a78252020-04-10 13:04:21 -07004934 }
4935 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004936 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004937 skip |=
4938 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4939 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4940 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4941 "commands pCreateInfos parameter.");
4942 }
4943 } else {
4944 if (pCreateInfos[i].basePipelineIndex != -1) {
4945 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4946 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4947 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4948 }
4949 }
4950 }
4951 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4952 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4953 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4954 }
4955 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4956 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4957 "vkCreateRayTracingPipelinesNV: flags must not include "
4958 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4959 }
4960 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4961 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4962 "vkCreateRayTracingPipelinesNV: flags must not include "
4963 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4964 }
4965 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4966 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4967 "vkCreateRayTracingPipelinesNV: flags must not include "
4968 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4969 }
4970 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4971 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4972 "vkCreateRayTracingPipelinesNV: flags must not include "
4973 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4974 }
4975 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4976 skip |= LogError(
4977 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4978 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4979 }
4980 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4981 skip |= LogError(
4982 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4983 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4984 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004985 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
4986 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
4987 "vkCreateRayTracingPipelinesNV: flags must not include "
4988 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
4989 }
4990 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
4991 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
4992 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
4993 }
Peter Chen85366392019-05-14 15:20:11 -04004994 }
4995
4996 return skip;
4997}
4998
sourav parmarcd5fb182020-07-17 12:58:44 -07004999bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5000 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5001 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005002 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005003 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005004 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5005 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5006 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005007 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005008 for (uint32_t i = 0; i < createInfoCount; i++) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005009 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5010 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5011 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5012 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5013 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5014 }
5015 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5016 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5017 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5018 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
5019 }
5020 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005021 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005022 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
5023 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07005024 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
5025 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
5026 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005027 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
5028 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
5029 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005030 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005031 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005032 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5033 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5034 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5035 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07005036 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07005037 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5038 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5039 }
5040 }
sourav parmarf4a78252020-04-10 13:04:21 -07005041 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005042 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
5043 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07005044 }
5045 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005046 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07005047 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07005048 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
5049 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005050 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005051 }
5052 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5053 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
5054 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07005055 }
5056 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
5057 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
5058 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
5059 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
5060 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
5061 skip |= LogError(
5062 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07005063 "vkCreateRayTracingPipelinesKHR: If flags includes "
5064 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005065 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5066 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
5067 "must not be VK_SHADER_UNUSED_KHR");
5068 }
5069 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
5070 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
5071 skip |= LogError(
5072 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07005073 "vkCreateRayTracingPipelinesKHR: If flags includes "
5074 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005075 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5076 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
5077 "element must not be VK_SHADER_UNUSED_KHR");
5078 }
5079 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005080 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
5081 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
5082 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
5083 skip |= LogError(
5084 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
5085 "vkCreateRayTracingPipelinesKHR: If "
5086 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
5087 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
5088 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5089 }
5090 }
sourav parmarf4a78252020-04-10 13:04:21 -07005091 }
5092 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5093 if (pCreateInfos[i].basePipelineIndex != -1) {
5094 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5095 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07005096 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07005097 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5098 "and pCreateInfos->basePipelineIndex is not -1.");
5099 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005100 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005101 skip |=
5102 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
5103 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
5104 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
5105 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
5106 "element.");
5107 }
sourav parmarf4a78252020-04-10 13:04:21 -07005108 }
5109 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005110 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005111 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005112 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005113 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
5114 "commands pCreateInfos parameter %d.",
5115 pCreateInfos[i].basePipelineIndex, createInfoCount);
5116 }
5117 } else {
5118 if (pCreateInfos[i].basePipelineIndex != -1) {
5119 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07005120 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005121 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5122 }
5123 }
5124 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005125 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
5126 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
5127 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
5128 "vkCreateRayTracingPipelinesKHR: If flags includes "
5129 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
5130 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005131 }
5132 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
5133 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
5134 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
5135 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
5136 "pLibraryInfo and pLibraryInterface must be NULL.");
5137 }
5138 if (pCreateInfos[i].pLibraryInfo) {
5139 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
5140 if (pCreateInfos[i].stageCount == 0) {
5141 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
5142 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5143 "stageCount must not be 0.");
5144 }
5145 if (pCreateInfos[i].groupCount == 0) {
5146 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
5147 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5148 "groupCount must not be 0.");
5149 }
5150 } else {
5151 if (pCreateInfos[i].pLibraryInterface == NULL) {
5152 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
5153 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
5154 "is greater than 0, its "
5155 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005156 }
5157 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005158 }
5159 if (pCreateInfos[i].pLibraryInterface) {
5160 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
5161 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
5162 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
5163 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
5164 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
5165 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005166 }
5167 if (deferredOperation != VK_NULL_HANDLE) {
5168 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
5169 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
5170 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
5171 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07005172 }
5173 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005174 }
5175
5176 return skip;
5177}
5178
Mike Schuchardt21638df2019-03-16 10:52:02 -07005179#ifdef VK_USE_PLATFORM_WIN32_KHR
5180bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
5181 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005182 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07005183 bool skip = false;
5184 if (!device_extensions.vk_khr_swapchain)
5185 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
5186 if (!device_extensions.vk_khr_get_surface_capabilities_2)
5187 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
5188 if (!device_extensions.vk_khr_surface)
5189 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
5190 if (!device_extensions.vk_khr_get_physical_device_properties_2)
5191 skip |=
5192 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
5193 if (!device_extensions.vk_ext_full_screen_exclusive)
5194 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
5195 skip |= validate_struct_type(
5196 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
5197 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
5198 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
5199 if (pSurfaceInfo != NULL) {
5200 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
5201 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
5202 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
5203
5204 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
5205 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
5206 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5207 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005208 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5209 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005210
5211 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5212 }
5213 return skip;
5214}
5215#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005216
5217bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5218 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005219 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005220 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5221 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005222 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005223 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5224 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5225 }
5226 return skip;
5227}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005228
5229bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005230 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005231 bool skip = false;
5232
5233 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005234 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
5235 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005236 }
5237
5238 return skip;
5239}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005240
5241bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005242 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005243 bool skip = false;
5244
5245 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005246 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5247 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005248 }
5249
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005250 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005251 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005252 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5253 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005254 }
5255
5256 return skip;
5257}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005258
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005259bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5260 uint32_t bindingCount, const VkBuffer *pBuffers,
5261 const VkDeviceSize *pOffsets) const {
5262 bool skip = false;
5263 if (firstBinding > device_limits.maxVertexInputBindings) {
5264 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5265 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
5266 device_limits.maxVertexInputBindings);
5267 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5268 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
5269 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5270 "maxVertexInputBindings (%u)",
5271 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5272 }
5273
Jeff Bolz165818a2020-05-08 11:19:03 -05005274 for (uint32_t i = 0; i < bindingCount; ++i) {
5275 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005276 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005277 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5278 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5279 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5280 } else {
5281 if (pOffsets[i] != 0) {
5282 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5283 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5284 }
5285 }
5286 }
5287 }
5288
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005289 return skip;
5290}
5291
Mark Lobodzinski84988402019-09-11 15:27:30 -06005292bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005293 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005294 bool skip = false;
5295 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005296 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5297 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005298 }
5299 return skip;
5300}
5301
5302bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005303 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005304 bool skip = false;
5305 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005306 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5307 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005308 }
5309 return skip;
5310}
Petr Kraus3d720392019-11-13 02:52:39 +01005311
5312bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5313 VkSemaphore semaphore, VkFence fence,
5314 uint32_t *pImageIndex) const {
5315 bool skip = false;
5316
5317 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005318 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5319 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005320 }
5321
5322 return skip;
5323}
5324
5325bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5326 uint32_t *pImageIndex) const {
5327 bool skip = false;
5328
5329 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005330 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5331 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005332 }
5333
5334 return skip;
5335}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005336
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005337bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5338 uint32_t firstBinding, uint32_t bindingCount,
5339 const VkBuffer *pBuffers,
5340 const VkDeviceSize *pOffsets,
5341 const VkDeviceSize *pSizes) const {
5342 bool skip = false;
5343
5344 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5345 for (uint32_t i = 0; i < bindingCount; ++i) {
5346 if (pOffsets[i] & 3) {
5347 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5348 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5349 }
5350 }
5351
5352 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5353 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5354 "%s: The firstBinding(%" PRIu32
5355 ") index is greater than or equal to "
5356 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5357 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5358 }
5359
5360 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5361 skip |=
5362 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5363 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5364 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5365 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5366 }
5367
5368 for (uint32_t i = 0; i < bindingCount; ++i) {
5369 // pSizes is optional and may be nullptr.
5370 if (pSizes != nullptr) {
5371 if (pSizes[i] != VK_WHOLE_SIZE &&
5372 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5373 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5374 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5375 ") is not VK_WHOLE_SIZE and is greater than "
5376 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5377 cmd_name, i, pSizes[i]);
5378 }
5379 }
5380 }
5381
5382 return skip;
5383}
5384
5385bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5386 uint32_t firstCounterBuffer,
5387 uint32_t counterBufferCount,
5388 const VkBuffer *pCounterBuffers,
5389 const VkDeviceSize *pCounterBufferOffsets) const {
5390 bool skip = false;
5391
5392 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5393 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5394 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5395 "%s: The firstCounterBuffer(%" PRIu32
5396 ") index is greater than or equal to "
5397 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5398 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5399 }
5400
5401 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5402 skip |=
5403 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5404 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5405 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5406 cmd_name, firstCounterBuffer, counterBufferCount,
5407 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5408 }
5409
5410 return skip;
5411}
5412
5413bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5414 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5415 const VkBuffer *pCounterBuffers,
5416 const VkDeviceSize *pCounterBufferOffsets) const {
5417 bool skip = false;
5418
5419 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5420 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5421 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5422 "%s: The firstCounterBuffer(%" PRIu32
5423 ") index is greater than or equal to "
5424 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5425 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5426 }
5427
5428 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5429 skip |=
5430 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5431 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5432 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5433 cmd_name, firstCounterBuffer, counterBufferCount,
5434 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5435 }
5436
5437 return skip;
5438}
5439
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005440bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5441 uint32_t firstInstance, VkBuffer counterBuffer,
5442 VkDeviceSize counterBufferOffset,
5443 uint32_t counterOffset, uint32_t vertexStride) const {
5444 bool skip = false;
5445
5446 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005447 skip |= LogError(
5448 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005449 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5450 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5451 }
5452
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005453 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08005454 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005455 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu64 ") must be a multiple of 4.", counterOffset);
5456 }
5457
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005458 return skip;
5459}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005460
5461bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5462 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5463 const VkAllocationCallbacks *pAllocator,
5464 VkSamplerYcbcrConversion *pYcbcrConversion,
5465 const char *apiName) const {
5466 bool skip = false;
5467
5468 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005469 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005470 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005471 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005472 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5473 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005474 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005475 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005476 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005477
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005478#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005479 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005480 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005481#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005482 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005483#endif
5484
sfricke-samsung1a72f942020-07-25 12:09:18 -07005485 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005486
5487 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005488 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005489 const VkComponentMapping components = pCreateInfo->components;
5490 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5491 if (FormatIsXChromaSubsampled(format) == true) {
5492 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5493 skip |=
5494 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005495 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5496 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005497 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005498 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005499
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005500 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5501 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5502 skip |= LogError(
5503 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5504 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5505 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5506 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5507 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005508
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005509 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5510 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5511 skip |=
5512 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005513 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5514 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005515 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005516 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005517
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005518 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5519 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5520 skip |=
5521 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005522 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5523 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005524 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005525 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005526
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005527 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005528 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5529 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5530 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005531 skip |=
5532 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005533 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5534 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005535 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5536 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005537 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005538 }
5539
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005540 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5541 // Checks same VU multiple ways in order to give a more useful error message
5542 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5543 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5544 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5545 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5546 skip |= LogError(
5547 device, vuid,
5548 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5549 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5550 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5551 string_VkComponentSwizzle(components.b));
5552 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005553
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005554 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5555 // 4 channel format = no issue
5556 // 3 = no [a]
5557 // 2 = no [b,a]
5558 // 1 = no [g,b,a]
5559 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5560 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5561
5562 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5563 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5564 skip |= LogError(device, vuid,
5565 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5566 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5567 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5568 string_VkComponentSwizzle(components.b));
5569 } else if ((channels < 3) &&
5570 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5571 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5572 skip |= LogError(device, vuid,
5573 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5574 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5575 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5576 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5577 string_VkComponentSwizzle(components.b));
5578 } else if ((channels < 2) &&
5579 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5580 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5581 skip |= LogError(device, vuid,
5582 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5583 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5584 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5585 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5586 string_VkComponentSwizzle(components.b));
5587 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005588 }
5589 }
5590
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005591 return skip;
5592}
5593
5594bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5595 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5596 const VkAllocationCallbacks *pAllocator,
5597 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5598 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5599 "vkCreateSamplerYcbcrConversion");
5600}
5601
5602bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5603 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5604 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5605 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5606 "vkCreateSamplerYcbcrConversionKHR");
5607}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005608
5609bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5610 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5611 bool skip = false;
5612 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5613 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5614
5615 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005616 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5617 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5618 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5619 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5620 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005621 }
5622 return skip;
5623}
sourav parmara96ab1a2020-04-25 16:28:23 -07005624
5625bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005626 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005627 bool skip = false;
5628 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5629 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5630 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5631 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005632 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005633 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5634 skip |= LogError(
5635 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
5636 "vkCopyAccelerationStructureToMemoryKHR: The "
5637 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5638 }
5639 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
5640 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
5641 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
5642 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
5643 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
5644 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005645 return skip;
5646}
5647
5648bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5649 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5650 bool skip = false;
5651 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5652 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5653 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5654 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5655 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005656 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
5657 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
5658 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress must be aligned to 256 bytes.",
5659 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07005660 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005661 return skip;
5662}
5663
5664bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5665 const char *api_name) const {
5666 bool skip = false;
5667 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5668 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5669 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5670 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5671 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5672 api_name);
5673 }
5674 return skip;
5675}
5676
5677bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005678 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005679 bool skip = false;
5680 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005681 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005682 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07005683 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07005684 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
5685 "vkCopyAccelerationStructureKHR: The "
5686 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005687 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005688 return skip;
5689}
5690
5691bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5692 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5693 bool skip = false;
5694 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5695 return skip;
5696}
5697
5698bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005699 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005700 bool skip = false;
5701 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005702 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005703 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5704 }
5705 return skip;
5706}
5707
5708bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005709 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005710 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005711 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005712 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005713 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5714 skip |= LogError(
5715 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
5716 "vkCopyMemoryToAccelerationStructureKHR: The "
5717 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005718 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005719 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
5720 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07005721 return skip;
5722}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005723
sourav parmara96ab1a2020-04-25 16:28:23 -07005724bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5725 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5726 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005727 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07005728 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
5729 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
5730 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress must be aligned to 256 bytes.",
5731 pInfo->src.deviceAddress);
5732 }
sourav parmar83c31b12020-05-06 12:30:54 -07005733 return skip;
5734}
5735bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5736 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5737 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5738 bool skip = false;
5739 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5740 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5741 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5742 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5743 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5744 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5745 }
5746 return skip;
5747}
5748bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5749 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5750 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5751 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005752 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005753 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
5754 skip |= LogError(
5755 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
5756 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
5757 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5758 }
sourav parmar83c31b12020-05-06 12:30:54 -07005759 if (dataSize < accelerationStructureCount * stride) {
5760 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5761 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5762 "accelerationStructureCount (%d) *stride(%zu).",
5763 dataSize, accelerationStructureCount, stride);
5764 }
5765 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5766 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5767 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5768 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5769 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5770 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5771 }
5772 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5773 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5774 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5775 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5776 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5777 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5778 stride);
5779 }
5780 }
5781 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5782 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5783 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5784 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5785 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5786 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5787 stride);
5788 }
5789 }
sourav parmar83c31b12020-05-06 12:30:54 -07005790 return skip;
5791}
5792bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5793 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5794 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005795 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005796 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
5797 skip |= LogError(
5798 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
5799 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
5800 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07005801 }
5802 return skip;
5803}
5804
5805bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07005806 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
5807 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
5808 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
5809 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07005810 uint32_t width, uint32_t height, uint32_t depth) const {
5811 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005812 // RayGen
5813 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
5814 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
5815 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07005816 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005817 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5818 0) {
5819 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
5820 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
5821 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5822 }
5823 // Callable
5824 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5825 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
5826 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
5827 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005828 }
5829 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5830 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5831 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005832 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5833 }
5834 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5835 0) {
5836 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
5837 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
5838 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005839 }
5840 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005841 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5842 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
5843 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
5844 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005845 }
5846 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5847 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07005848 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
5849 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07005850 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005851 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5852 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
5853 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
5854 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5855 }
sourav parmar83c31b12020-05-06 12:30:54 -07005856 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005857 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5858 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
5859 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
5860 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07005861 }
5862 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5863 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5864 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005865 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5866 }
5867 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5868 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
5869 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
5870 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5871 }
5872 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
5873 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
5874 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
5875 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
5876 }
5877 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
5878 skip |=
5879 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
5880 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
5881 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07005882 }
5883
sourav parmarcd5fb182020-07-17 12:58:44 -07005884 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
5885 skip |=
5886 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
5887 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
5888 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
5889 }
5890
5891 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
5892 skip |=
5893 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
5894 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
5895 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07005896 }
5897 return skip;
5898}
5899
sourav parmarcd5fb182020-07-17 12:58:44 -07005900bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
5901 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
5902 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
5903 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07005904 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005905 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005906 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
5907 skip |= LogError(
5908 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
5909 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
5910 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005911 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005912 // RayGen
5913 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
5914 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
5915 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07005916 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005917 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5918 0) {
5919 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
5920 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
5921 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5922 }
5923 // Callabe
5924 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5925 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
5926 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
5927 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005928 }
5929 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5930 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07005931 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
5932 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5933 }
5934 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5935 0) {
5936 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
5937 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
5938 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005939 }
5940 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005941 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5942 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
5943 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
5944 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005945 }
5946 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5947 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07005948 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
5949 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07005950 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005951 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5952 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
5953 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
5954 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5955 }
sourav parmar83c31b12020-05-06 12:30:54 -07005956 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005957 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5958 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
5959 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
5960 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005961 }
5962 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5963 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07005964 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
5965 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5966 }
5967 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5968 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
5969 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
5970 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005971 }
5972
sourav parmarcd5fb182020-07-17 12:58:44 -07005973 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
5974 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
5975 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07005976 }
5977 return skip;
5978}
5979bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5980 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5981 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5982 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5983 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5984 uint32_t width, uint32_t height, uint32_t depth) const {
5985 bool skip = false;
5986 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5987 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5988 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5989 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5990 }
5991 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5992 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5993 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5994 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5995 }
5996 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5997 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5998 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5999 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
6000 }
6001
6002 // hitShader
6003 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6004 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
6005 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
6006 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6007 }
6008 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6009 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
6010 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
6011 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6012 }
6013 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6014 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
6015 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
6016 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6017 }
6018
6019 // missShader
6020 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6021 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
6022 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
6023 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6024 }
6025 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6026 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
6027 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
6028 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6029 }
6030 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6031 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
6032 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
6033 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6034 }
6035
6036 // raygenShader
6037 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6038 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
6039 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07006040 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6041 }
6042 if (width > device_limits.maxComputeWorkGroupCount[0]) {
6043 skip |=
6044 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
6045 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
6046 }
6047 if (height > device_limits.maxComputeWorkGroupCount[1]) {
6048 skip |=
6049 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
6050 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
6051 }
6052 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
6053 skip |=
6054 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
6055 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07006056 }
6057 return skip;
6058}
6059
sourav parmar83c31b12020-05-06 12:30:54 -07006060bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006061 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
6062 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006063 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006064 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6065 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006066 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
6067 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006068 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07006069 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
6070 }
6071 return skip;
6072}
6073
Piers Daniell39842ee2020-07-10 16:42:33 -06006074bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
6075 const VkViewport *pViewports) const {
6076 bool skip = false;
6077
6078 if (!physical_device_features.multiViewport) {
6079 if (viewportCount != 1) {
6080 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
6081 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
6082 ") is not 1.",
6083 viewportCount);
6084 }
6085 } else { // multiViewport enabled
6086 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
6087 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
6088 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
6089 ") must "
6090 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6091 viewportCount, device_limits.maxViewports);
6092 }
6093 }
6094
6095 if (pViewports) {
6096 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
6097 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
6098 const char *fn_name = "vkCmdSetViewportWithCountEXT";
6099 skip |= manual_PreCallValidateViewport(
6100 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
6101 }
6102 }
6103
6104 return skip;
6105}
6106
6107bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
6108 const VkRect2D *pScissors) const {
6109 bool skip = false;
6110
6111 if (!physical_device_features.multiViewport) {
6112 if (scissorCount != 1) {
6113 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
6114 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6115 ") must "
6116 "be 1 when the multiViewport feature is disabled.",
6117 scissorCount);
6118 }
6119 } else { // multiViewport enabled
6120 if (scissorCount == 0) {
6121 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6122 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6123 ") must "
6124 "be great than zero.",
6125 scissorCount);
6126 } else if (scissorCount > device_limits.maxViewports) {
6127 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6128 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6129 ") must "
6130 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6131 scissorCount, device_limits.maxViewports);
6132 }
6133 }
6134
6135 if (pScissors) {
6136 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
6137 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
6138
6139 if (scissor.offset.x < 0) {
6140 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6141 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
6142 scissor.offset.x);
6143 }
6144
6145 if (scissor.offset.y < 0) {
6146 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6147 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
6148 scissor.offset.y);
6149 }
6150
6151 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
6152 if (x_sum > INT32_MAX) {
6153 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
6154 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6155 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6156 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
6157 }
6158
6159 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
6160 if (y_sum > INT32_MAX) {
6161 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
6162 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6163 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6164 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
6165 }
6166 }
6167 }
6168
6169 return skip;
6170}
6171
6172bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6173 uint32_t bindingCount, const VkBuffer *pBuffers,
6174 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
6175 const VkDeviceSize *pStrides) const {
6176 bool skip = false;
6177 if (firstBinding >= device_limits.maxVertexInputBindings) {
6178 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
6179 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
6180 firstBinding, device_limits.maxVertexInputBindings);
6181 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6182 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
6183 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
6184 "maxVertexInputBindings (%u)",
6185 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6186 }
6187
6188 for (uint32_t i = 0; i < bindingCount; ++i) {
6189 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006190 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06006191 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
6192 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
6193 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
6194 } else {
6195 if (pOffsets[i] != 0) {
6196 skip |=
6197 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
6198 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
6199 }
6200 }
6201 }
6202 if (pStrides) {
6203 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
6204 skip |=
6205 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
6206 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%u) must be less than maxVertexInputBindingStride (%u)", i,
6207 pStrides[i], device_limits.maxVertexInputBindingStride);
6208 }
6209 }
6210 }
6211
6212 return skip;
6213}
sourav parmarcd5fb182020-07-17 12:58:44 -07006214
6215bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6216 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6217 bool skip = false;
6218 for (uint32_t i = 0; i < infoCount; ++i) {
6219 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6220 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6221 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6222 }
6223 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6224 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6225 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6226 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6227 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6228 api_name);
6229 }
6230 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6231 skip |=
6232 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6233 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6234 }
6235 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6236 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6237 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6238 }
6239 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6240 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6241 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6242 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6243 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6244 api_name);
6245 }
6246 if (pInfos[i].pGeometries) {
6247 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6248 skip |= validate_ranged_enum(
6249 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6250 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6251 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6252 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006253 skip |= validate_struct_type(
6254 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6255 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6256 &(pInfos[i].pGeometries[j].geometry.triangles),
6257 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6258 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6259 skip |= validate_struct_pnext(
6260 api_name,
6261 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6262 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6263 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6264 skip |=
6265 validate_ranged_enum(api_name,
6266 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6267 ParameterName::IndexVector{i, j}),
6268 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6269 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6270 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6271 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6272 &pInfos[i].pGeometries[j].geometry.triangles,
6273 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6274 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6275 skip |= validate_ranged_enum(
6276 api_name,
6277 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6278 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6279 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6280
6281 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6282 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6283 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6284 }
6285 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6286 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6287 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6288 skip |=
6289 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6290 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6291 api_name);
6292 }
6293 }
6294 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6295 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6296 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6297 &pInfos[i].pGeometries[j].geometry.instances,
6298 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6299 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6300 skip |= validate_struct_type(
6301 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6302 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6303 &(pInfos[i].pGeometries[j].geometry.instances),
6304 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6305 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6306 skip |= validate_struct_pnext(
6307 api_name,
6308 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6309 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6310 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6311
6312 skip |= validate_bool32(api_name,
6313 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6314 ParameterName::IndexVector{i, j}),
6315 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6316 }
6317 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6318 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6319 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6320 &pInfos[i].pGeometries[j].geometry.aabbs,
6321 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6322 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6323 skip |= validate_struct_type(
6324 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6325 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6326 &(pInfos[i].pGeometries[j].geometry.aabbs),
6327 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6328 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6329 skip |= validate_struct_pnext(
6330 api_name,
6331 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6332 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6333 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6334 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6335 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6336 "(%s):stride must be less than or equal to 2^32-1", api_name);
6337 }
6338 }
6339 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6340 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6341 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6342 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6343 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6344 api_name);
6345 }
6346 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6347 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6348 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6349 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6350 "of elements of"
6351 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6352 api_name);
6353 }
6354 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6355 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6356 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6357 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6358 api_name);
6359 }
6360 }
6361 }
6362 }
6363 if (pInfos[i].ppGeometries != NULL) {
6364 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6365 skip |= validate_ranged_enum(
6366 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6367 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6368 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6369 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006370 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6371 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6372 &pInfos[i].ppGeometries[j]->geometry.triangles,
6373 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6374 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6375 skip |= validate_struct_type(
6376 api_name,
6377 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6378 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6379 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6380 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6381 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6382 skip |= validate_struct_pnext(
6383 api_name,
6384 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6385 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6386 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6387 skip |= validate_ranged_enum(api_name,
6388 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6389 ParameterName::IndexVector{i, j}),
6390 "VkFormat", AllVkFormatEnums,
6391 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6392 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6393 skip |= validate_ranged_enum(api_name,
6394 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6395 ParameterName::IndexVector{i, j}),
6396 "VkIndexType", AllVkIndexTypeEnums,
6397 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6398 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6399 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6400 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6401 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6402 }
6403 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6404 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6405 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6406 skip |=
6407 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6408 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6409 api_name);
6410 }
6411 }
6412 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6413 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6414 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6415 &pInfos[i].ppGeometries[j]->geometry.instances,
6416 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6417 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6418 skip |= validate_struct_type(
6419 api_name,
6420 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6421 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6422 &(pInfos[i].ppGeometries[j]->geometry.instances),
6423 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6424 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6425 skip |= validate_struct_pnext(
6426 api_name,
6427 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6428 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6429 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6430 skip |= validate_bool32(api_name,
6431 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6432 ParameterName::IndexVector{i, j}),
6433 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6434 }
6435 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6436 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6437 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6438 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6439 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6440 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6441 skip |= validate_struct_type(
6442 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6443 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6444 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6445 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6446 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6447 skip |= validate_struct_pnext(
6448 api_name,
6449 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6450 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6451 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6452 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6453 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6454 "(%s):stride must be less than or equal to 2^32-1", api_name);
6455 }
6456 }
6457 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6458 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6459 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6460 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6461 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6462 api_name);
6463 }
6464 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6465 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6466 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6467 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6468 "of elements of"
6469 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6470 api_name);
6471 }
6472 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6473 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6474 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6475 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6476 api_name);
6477 }
6478 }
6479 }
6480 }
6481 }
6482 return skip;
6483}
6484bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6485 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6486 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6487 bool skip = false;
6488 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6489 for (uint32_t i = 0; i < infoCount; ++i) {
6490 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6491 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6492 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6493 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6494 "scratchData.deviceAddress member must be a multiple of "
6495 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6496 }
6497 for (uint32_t k = 0; k < infoCount; ++k) {
6498 if (i == k) continue;
6499 bool found = false;
6500 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6501 skip |= LogError(
6502 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6503 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6504 "not be "
6505 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6506 i, k);
6507 found = true;
6508 }
6509 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6510 skip |= LogError(
6511 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
6512 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
6513 "not be "
6514 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6515 i, k);
6516 found = true;
6517 }
6518 if (found) break;
6519 }
6520 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6521 if (pInfos[i].pGeometries) {
6522 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6523 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6524 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6525 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6526 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6527 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6528 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6529 }
6530 } else {
6531 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6532 skip |=
6533 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6534 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6535 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6536 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6537 }
6538 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006539 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006540 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6541 skip |= LogError(
6542 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6543 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6544 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6545 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006546 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6547 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006548 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6549 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6550 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6551 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6552 }
6553 }
6554 } else if (pInfos[i].ppGeometries) {
6555 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6556 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6557 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6558 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6559 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6560 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6561 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6562 }
6563 } else {
6564 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6565 skip |=
6566 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6567 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6568 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6569 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6570 }
6571 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006572 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006573 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6574 skip |= LogError(
6575 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6576 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6577 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6578 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006579 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6580 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006581 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6582 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6583 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6584 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6585 }
6586 }
6587 }
6588 }
6589 }
6590 return skip;
6591}
6592
6593bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
6594 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6595 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
6596 const uint32_t *const *ppMaxPrimitiveCounts) const {
6597 bool skip = false;
6598 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
6599 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006600 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006601 if (!ray_tracing_acceleration_structure_features ||
6602 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
6603 skip |= LogError(
6604 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
6605 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
6606 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
6607 }
6608 for (uint32_t i = 0; i < infoCount; ++i) {
6609 if (pInfos[i].mode == VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR) {
6610 if (pInfos[i].srcAccelerationStructure == VK_NULL_HANDLE) {
6611 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03666",
6612 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, if its mode member is "
6613 "VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, its srcAccelerationStructure member must not be "
6614 "VK_NULL_HANDLE.");
6615 }
6616 }
6617 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6618 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6619 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
6620 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
6621 "scratchData.deviceAddress member must be a multiple of "
6622 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6623 }
6624 for (uint32_t k = 0; k < infoCount; ++k) {
6625 if (i == k) continue;
6626 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6627 skip |=
6628 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
6629 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
6630 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
6631 "any other element [%d) of pInfos.",
6632 i, k);
6633 break;
6634 }
6635 }
6636 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6637 if (pInfos[i].pGeometries) {
6638 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6639 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6640 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6641 skip |= LogError(
6642 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6643 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6644 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6645 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6646 }
6647 } else {
6648 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6649 skip |= LogError(
6650 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6651 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6652 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6653 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6654 }
6655 }
6656 }
6657 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6658 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6659 skip |= LogError(
6660 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6661 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6662 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6663 }
6664 }
6665 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6666 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
6667 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6668 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6669 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6670 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6671 }
6672 }
6673 } else if (pInfos[i].ppGeometries) {
6674 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6675 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6676 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6677 skip |= LogError(
6678 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6679 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6680 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6681 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6682 }
6683 } else {
6684 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6685 skip |= LogError(
6686 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6687 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6688 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6689 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6690 }
6691 }
6692 }
6693 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6694 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6695 skip |= LogError(
6696 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6697 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6698 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6699 }
6700 }
6701 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6702 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
6703 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6704 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6705 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6706 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6707 }
6708 }
6709 }
6710 }
6711 }
6712 return skip;
6713}
6714
6715bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
6716 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
6717 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6718 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6719 bool skip = false;
6720 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
6721 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006722 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006723 if (!ray_tracing_acceleration_structure_features ||
6724 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6725 skip |=
6726 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
6727 "vkBuildAccelerationStructuresKHR: The "
6728 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
6729 }
6730 for (uint32_t i = 0; i < infoCount; ++i) {
6731 for (uint32_t j = 0; j < infoCount; ++j) {
6732 if (i == j) continue;
6733 bool found = false;
6734 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6735 skip |= LogError(
6736 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6737 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
6738 "not be "
6739 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6740 i, j);
6741 found = true;
6742 }
6743 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6744 skip |= LogError(
6745 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
6746 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
6747 "not be "
6748 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6749 i, j);
6750 found = true;
6751 }
6752 if (found) break;
6753 }
6754 }
6755 return skip;
6756}
6757
6758bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
6759 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
6760 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
6761 bool skip = false;
6762 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
6763 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006764 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
6765 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006766 if (!(ray_tracing_pipeline_features || ray_query_features) ||
6767 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
6768 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
6769 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
6770 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
6771 }
6772 return skip;
6773}
sfricke-samsungecafb192021-01-17 08:21:14 -08006774
6775bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
6776 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
6777 const VkAllocationCallbacks *pAllocator,
6778 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
6779 bool skip = false;
6780 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
6781 if (private_data_features && private_data_features->privateData == VK_FALSE) {
6782 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
6783 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
6784 }
6785 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07006786}