blob: e2295e3066019fa7be8a7747243a87ca2cae97ee [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
Tony-LunarG3c287f62020-12-17 12:39:49 -070039static std::unordered_map<VkCommandBuffer, VkCommandPool> secondary_cb_map{};
40static 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;
195 std::unordered_set<std::string> dev_exts_enumerated{};
196 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) {
520 std::unordered_set<uint32_t> set;
521
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;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600688 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
689 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
690 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
691 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700692 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
693 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
694 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600695 }
696
697 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
698 // queueFamilyIndexCount uint32_t values
699 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700700 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
701 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
702 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
703 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600704 }
705 }
706
Dave Houlton413a6782018-05-22 13:01:54 -0600707 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700708 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600709 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700710 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600711 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700712 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600713
Dave Houlton413a6782018-05-22 13:01:54 -0600714 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700715 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600716 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700717 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600718
Dave Houlton130c0212018-01-29 13:39:56 -0700719 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700720 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
721 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700722 skip |= LogError(
723 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600724 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
725 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700726 }
727
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600728 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100729 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
730 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700731 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
732 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
733 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600734 }
735
736 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100737 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
738 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700739 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
740 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
741 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
742 ") are not equal.",
743 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100744 }
745
746 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700747 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
748 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
749 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
750 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100751 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600752 }
753
754 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700755 skip |= LogError(
756 device, "VUID-VkImageCreateInfo-imageType-00957",
757 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600758 }
759 }
760
Dave Houlton130c0212018-01-29 13:39:56 -0700761 // 3D image may have only 1 layer
762 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700763 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
764 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700765 }
766
Dave Houlton130c0212018-01-29 13:39:56 -0700767 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
768 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
769 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
770 // At least one of the legal attachment bits must be set
771 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700772 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
773 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700774 }
775 // No flags other than the legal attachment bits may be set
776 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
777 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700778 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
779 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700780 }
781 }
782
Jeff Bolzef40fec2018-09-01 22:04:34 -0500783 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700784 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500785 // Max mip levels is different for corner-sampled images vs normal images.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700786 uint32_t max_mip_levels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
787 ? static_cast<uint32_t>(ceil(log2(max_dim)))
788 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
789 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600790 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700791 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
792 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
793 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600794 }
795
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600796 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700797 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
798 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
799 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600800 }
801
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700802 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700803 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
804 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
805 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100806 }
807
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700808 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
809 skip |= LogError(
810 device, "VUID-VkImageCreateInfo-flags-01924",
811 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
812 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
813 }
814
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600815 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
816 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
817 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
818 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700819 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
820 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
821 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600822 }
823
824 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
825 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
826 // Linear tiling is unsupported
827 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700828 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700829 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
830 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600831 }
832
833 // Sparse 1D image isn't valid
834 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700835 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
836 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600837 }
838
839 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700840 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700841 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
842 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
843 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600844 }
845
846 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700847 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700848 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
849 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
850 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600851 }
852
853 // Multi-sample 2D image when device doesn't support it
854 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700855 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600856 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700857 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
858 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
859 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700860 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600861 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700862 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
863 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
864 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700865 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600866 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700867 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
868 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
869 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700870 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600871 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700872 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
873 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
874 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600875 }
876 }
877 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500878
Jeff Bolz9af91c52018-09-01 21:53:57 -0500879 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
880 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700881 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
882 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
883 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500884 }
885 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700886 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
887 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
888 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500889 }
890 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700891 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
892 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
893 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500894 }
895 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500896
897 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600898 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700899 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
900 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
901 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500902 }
903
sfricke-samsung61a57c02021-01-10 21:35:12 -0800904 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700905 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
906 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800907 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
908 "depth/stencil format.",
909 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500910 }
911
Dave Houlton142c4cb2018-10-17 15:04:41 -0600912 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700913 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
914 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
915 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
916 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500917 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600918 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700919 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
920 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
921 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
922 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500923 }
924 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500925
sfricke-samsung8f658d42020-05-03 20:12:24 -0700926 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -0800927 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -0700928 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
929 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800930 "format (%s) must be a depth or depth/stencil format.",
931 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -0700932 }
933
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700934 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500935 if (image_stencil_struct != nullptr) {
936 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
937 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
938 // No flags other than the legal attachment bits may be set
939 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
940 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700941 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
942 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
943 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
944 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500945 }
946 }
947
sfricke-samsung61a57c02021-01-10 21:35:12 -0800948 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -0500949 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
950 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
951 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700952 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
953 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
954 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
955 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500956 }
957
958 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
959 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700960 LogError(device, "VUID-VkImageCreateInfo-format-02537",
961 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
962 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
963 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500964 }
965 }
966
967 if (!physical_device_features.shaderStorageImageMultisample &&
968 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
969 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
970 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700971 LogError(device, "VUID-VkImageCreateInfo-format-02538",
972 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
973 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
974 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500975 }
976
977 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
978 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700979 skip |= LogError(
980 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500981 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
982 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
983 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
984 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
985 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700986 skip |= LogError(
987 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500988 "vkCreateImage(): Depth-stencil image in which usage does not include "
989 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
990 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
991 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
992 }
993
994 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
995 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700996 skip |= LogError(
997 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500998 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
999 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1000 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1001 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1002 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001003 skip |= LogError(
1004 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001005 "vkCreateImage(): Depth-stencil image in which usage does not include "
1006 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1007 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1008 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1009 }
1010 }
1011 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001012
1013 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1014 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1015 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1016 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1017 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1018 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001019
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001020 std::vector<uint64_t> image_create_drm_format_modifiers;
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001021 if (device_extensions.vk_ext_image_drm_format_modifier) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001022 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1023 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001024 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1025 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1026 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1027 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1028 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1029 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1030 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001031 } else if (drm_format_mod_list != nullptr) {
1032 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1033 } else if (drm_format_mod_list != nullptr) {
1034 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1035 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1036 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001037 }
1038 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1039 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1040 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1041 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1042 "in the pNext chain");
1043 }
1044 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001045
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001046 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001047 bool image_create_maybe_linear = false;
1048 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1049 image_create_maybe_linear = true;
1050 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1051 image_create_maybe_linear = false;
1052 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1053 image_create_maybe_linear =
1054 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001055 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001056 }
1057
1058 // If multi-sample, validate type, usage, tiling and mip levels.
1059 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
1060 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
1061 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1062 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1063 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1064 }
1065
1066 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
1067 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1068 image_create_maybe_linear)) {
1069 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1070 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1071 }
1072
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001073 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1074 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1075 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1076 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1077 "imageType must be VK_IMAGE_TYPE_2D.");
1078 }
1079 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1080 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1081 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1082 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1083 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001084 }
1085 if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
1086 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1087 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1088 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1089 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1090 }
1091 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1092 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1093 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1094 "imageType must be VK_IMAGE_TYPE_2D.");
1095 }
1096 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
1097 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1098 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1099 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1100 }
1101 if (pCreateInfo->mipLevels != 1) {
1102 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1103 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1104 pCreateInfo->mipLevels);
1105 }
1106 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001107
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001108 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001109 if (swapchain_create_info != nullptr) {
1110 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1111 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1112 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1113 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1114 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1115 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1116
1117 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1118 // also implicitly forces the check above that extent.depth is 1
1119 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1120 string_VkImageType(pCreateInfo->imageType));
1121 }
1122 if (pCreateInfo->mipLevels != 1) {
1123 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1124 pCreateInfo->mipLevels);
1125 }
1126 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1127 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1128 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1129 }
1130 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1131 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1132 base_message, string_VkImageTiling(pCreateInfo->tiling));
1133 }
1134 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1135 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1136 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1137 }
1138 const VkImageCreateFlags valid_flags =
1139 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001140 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001141 if ((pCreateInfo->flags & ~valid_flags) != 0) {
1142 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
1143 pCreateInfo->flags);
1144 }
1145 }
1146 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001147
1148 // If Chroma subsampled format ( _420_ or _422_ )
1149 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1150 skip |=
1151 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1152 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1153 ") must be a multiple of 2.",
1154 string_VkFormat(image_format), pCreateInfo->extent.width);
1155 }
1156 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1157 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1158 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1159 ") must be a multiple of 2.",
1160 string_VkFormat(image_format), pCreateInfo->extent.height);
1161 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001162 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001163
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001164 return skip;
1165}
1166
Jeff Bolz99e3f632020-03-24 22:59:22 -05001167bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1168 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1169 bool skip = false;
1170
1171 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001172 // Validate feature set if using CUBE_ARRAY
1173 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1174 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1175 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1176 "enabling the imageCubeArray feature.");
1177 }
1178
Jeff Bolz99e3f632020-03-24 22:59:22 -05001179 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1180 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1181 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001182 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001183 pCreateInfo->subresourceRange.layerCount);
1184 }
1185 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001186 skip |= LogError(
1187 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1188 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1189 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001190 }
1191 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001192
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001193 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001194 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1195 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1196 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1197 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1198 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1199 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1200 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1201 }
1202 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1203 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1204 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1205 "not an ASTC format.",
1206 string_VkFormat(pCreateInfo->format));
1207 }
1208 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001209
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001210 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001211 if (ycbcr_conversion != nullptr) {
1212 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1213 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1214 skip |= LogError(
1215 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1216 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1217 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1218 "r swizzle = %s\n"
1219 "g swizzle = %s\n"
1220 "b swizzle = %s\n"
1221 "a swizzle = %s\n",
1222 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1223 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1224 }
1225 }
1226 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001227 }
1228 return skip;
1229}
1230
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001231bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001232 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001233 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001234
1235 // Note: for numerical correctness
1236 // - float comparisons should expect NaN (comparison always false).
1237 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1238
1239 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001240 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001241 if (v1_f <= 0.0f) return true;
1242
1243 float intpart;
1244 const float fract = modff(v1_f, &intpart);
1245
1246 assert(std::numeric_limits<float>::radix == 2);
1247 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1248 if (intpart >= u32_max_plus1) return false;
1249
1250 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001251 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001252 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001253 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001254 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001255 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001256 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001257 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001258 };
1259
1260 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1261 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1262 return (v1_f <= v2_f);
1263 };
1264
1265 // width
1266 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001267 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001268
1269 if (!(viewport.width > 0.0f)) {
1270 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001271 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1272 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001273 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1274 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001275 skip |= LogError(object, "VUID-VkViewport-width-01771",
1276 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1277 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001278 }
1279
1280 // height
1281 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001282 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001283 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001284
1285 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1286 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001287 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1288 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001289 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1290 height_healthy = false;
1291
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001292 skip |= LogError(object, "VUID-VkViewport-height-01773",
1293 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1294 ").",
1295 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001296 }
1297
1298 // x
1299 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001300 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001301 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001302 skip |= LogError(object, "VUID-VkViewport-x-01774",
1303 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1304 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001305 }
1306
1307 // x + width
1308 if (x_healthy && width_healthy) {
1309 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001310 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001311 skip |= LogError(
1312 object, "VUID-VkViewport-x-01232",
1313 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1314 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1315 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001316 }
1317 }
1318
1319 // y
1320 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001321 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001322 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001323 skip |= LogError(object, "VUID-VkViewport-y-01775",
1324 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1325 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001326 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001327 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001328 skip |= LogError(object, "VUID-VkViewport-y-01776",
1329 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1330 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001331 }
1332
1333 // y + height
1334 if (y_healthy && height_healthy) {
1335 const float boundary = viewport.y + viewport.height;
1336
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001337 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001338 skip |= LogError(object, "VUID-VkViewport-y-01233",
1339 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1340 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1341 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001342 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001343 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001344 LogError(object, "VUID-VkViewport-y-01777",
1345 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1346 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1347 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001348 }
1349 }
1350
sfricke-samsungfd06d422021-01-22 02:17:21 -08001351 // 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 -07001352 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001353 // minDepth
1354 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001355 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001356 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001357 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1358 "[0.0, 1.0] range.",
1359 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001360 }
1361
1362 // maxDepth
1363 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001364 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001365 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001366 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1367 "[0.0, 1.0] range.",
1368 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001369 }
1370 }
1371
1372 return skip;
1373}
1374
Dave Houlton142c4cb2018-10-17 15:04:41 -06001375struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001376 VkShadingRatePaletteEntryNV shadingRate;
1377 uint32_t width;
1378 uint32_t height;
1379};
1380
1381// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001382static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001383 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1384 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1385 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1386 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1387 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1388 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001389};
1390
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001391bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001392 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001393
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001394 SampleOrderInfo *sample_order_info;
1395 uint32_t info_idx = 0;
1396 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1397 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1398 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001399 break;
1400 }
1401 }
1402
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001403 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001404 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1405 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1406 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001407 return skip;
1408 }
1409
Dave Houlton142c4cb2018-10-17 15:04:41 -06001410 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001411 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001412 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1413 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1414 ") must "
1415 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1416 "is set in framebufferNoAttachmentsSampleCounts.",
1417 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001418 }
1419
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001420 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001421 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1422 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1423 ") must "
1424 "be equal to the product of sampleCount (=%" PRIu32
1425 "), the fragment width for shadingRate "
1426 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001427 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001428 }
1429
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001430 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001431 skip |= LogError(
1432 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001433 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1434 ") must "
1435 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001436 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001437 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001438
1439 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001440 // the first width*height*sampleCount bits to all be set. Note: There is no
1441 // guarantee that 64 bits is enough, but practically it's unlikely for an
1442 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001443 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001444 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001445 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001446 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1447 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001448 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1449 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001450 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001451 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001452 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1453 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001454 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001455 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001456 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1457 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001458 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001459 uint32_t idx =
1460 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1461 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001462 }
1463
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001464 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1465 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001466 skip |= LogError(
1467 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001468 "The array pSampleLocations must contain exactly one entry for "
1469 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001470 }
1471
1472 return skip;
1473}
1474
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001475bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1476 uint32_t createInfoCount,
1477 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1478 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001479 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001480 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001481
1482 if (pCreateInfos != nullptr) {
1483 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001484 bool has_dynamic_viewport = false;
1485 bool has_dynamic_scissor = false;
1486 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001487 bool has_dynamic_depth_bias = false;
1488 bool has_dynamic_blend_constant = false;
1489 bool has_dynamic_depth_bounds = false;
1490 bool has_dynamic_stencil_compare = false;
1491 bool has_dynamic_stencil_write = false;
1492 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001493 bool has_dynamic_viewport_w_scaling_nv = false;
1494 bool has_dynamic_discard_rectangle_ext = false;
1495 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001496 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001497 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001498 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001499 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001500 bool has_dynamic_cull_mode = false;
1501 bool has_dynamic_front_face = false;
1502 bool has_dynamic_primitive_topology = false;
1503 bool has_dynamic_viewport_with_count = false;
1504 bool has_dynamic_scissor_with_count = false;
1505 bool has_dynamic_vertex_input_binding_stride = false;
1506 bool has_dynamic_depth_test_enable = false;
1507 bool has_dynamic_depth_write_enable = false;
1508 bool has_dynamic_depth_compare_op = false;
1509 bool has_dynamic_depth_bounds_test_enable = false;
1510 bool has_dynamic_stencil_test_enable = false;
1511 bool has_dynamic_stencil_op = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07001512 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
1513 skip |=
1514 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
1515 "vkCreateGraphicsPipelines: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR");
1516 }
Petr Kraus299ba622017-11-24 03:09:03 +01001517 if (pCreateInfos[i].pDynamicState != nullptr) {
1518 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1519 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1520 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001521 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1522 if (has_dynamic_viewport == true) {
1523 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1524 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1525 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1526 i);
1527 }
1528 has_dynamic_viewport = true;
1529 }
1530 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1531 if (has_dynamic_scissor == true) {
1532 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1533 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1534 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1535 i);
1536 }
1537 has_dynamic_scissor = true;
1538 }
1539 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1540 if (has_dynamic_line_width == true) {
1541 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1542 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1543 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1544 i);
1545 }
1546 has_dynamic_line_width = true;
1547 }
1548 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1549 if (has_dynamic_depth_bias == true) {
1550 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1551 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1552 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1553 i);
1554 }
1555 has_dynamic_depth_bias = true;
1556 }
1557 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1558 if (has_dynamic_blend_constant == true) {
1559 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1560 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1561 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1562 i);
1563 }
1564 has_dynamic_blend_constant = true;
1565 }
1566 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1567 if (has_dynamic_depth_bounds == true) {
1568 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1569 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1570 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1571 i);
1572 }
1573 has_dynamic_depth_bounds = true;
1574 }
1575 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1576 if (has_dynamic_stencil_compare == true) {
1577 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1578 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1579 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1580 i);
1581 }
1582 has_dynamic_stencil_compare = true;
1583 }
1584 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1585 if (has_dynamic_stencil_write == true) {
1586 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1587 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1588 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1589 i);
1590 }
1591 has_dynamic_stencil_write = true;
1592 }
1593 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1594 if (has_dynamic_stencil_reference == true) {
1595 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1596 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1597 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1598 i);
1599 }
1600 has_dynamic_stencil_reference = true;
1601 }
1602 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1603 if (has_dynamic_viewport_w_scaling_nv == true) {
1604 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1605 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1606 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1607 i);
1608 }
1609 has_dynamic_viewport_w_scaling_nv = true;
1610 }
1611 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1612 if (has_dynamic_discard_rectangle_ext == true) {
1613 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1614 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1615 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1616 i);
1617 }
1618 has_dynamic_discard_rectangle_ext = true;
1619 }
1620 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1621 if (has_dynamic_sample_locations_ext == true) {
1622 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1623 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1624 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1625 i);
1626 }
1627 has_dynamic_sample_locations_ext = true;
1628 }
1629 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1630 if (has_dynamic_exclusive_scissor_nv == true) {
1631 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1632 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1633 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1634 i);
1635 }
1636 has_dynamic_exclusive_scissor_nv = true;
1637 }
1638 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1639 if (has_dynamic_shading_rate_palette_nv == true) {
1640 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1641 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1642 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1643 i);
1644 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001645 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001646 }
1647 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1648 if (has_dynamic_viewport_course_sample_order_nv == true) {
1649 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1650 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1651 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1652 i);
1653 }
1654 has_dynamic_viewport_course_sample_order_nv = true;
1655 }
1656 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1657 if (has_dynamic_line_stipple == true) {
1658 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1659 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1660 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1661 i);
1662 }
1663 has_dynamic_line_stipple = true;
1664 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001665 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1666 if (has_dynamic_cull_mode) {
1667 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1668 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1669 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1670 i);
1671 }
1672 has_dynamic_cull_mode = true;
1673 }
1674 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1675 if (has_dynamic_front_face) {
1676 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1677 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1678 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1679 i);
1680 }
1681 has_dynamic_front_face = true;
1682 }
1683 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1684 if (has_dynamic_primitive_topology) {
1685 skip |= LogError(
1686 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1687 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1688 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1689 i);
1690 }
1691 has_dynamic_primitive_topology = true;
1692 }
1693 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1694 if (has_dynamic_viewport_with_count) {
1695 skip |= LogError(
1696 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1697 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1698 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1699 i);
1700 }
1701 has_dynamic_viewport_with_count = true;
1702 }
1703 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1704 if (has_dynamic_scissor_with_count) {
1705 skip |= LogError(
1706 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1707 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1708 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1709 i);
1710 }
1711 has_dynamic_scissor_with_count = true;
1712 }
1713 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1714 if (has_dynamic_vertex_input_binding_stride) {
1715 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1716 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1717 "listed twice in the "
1718 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1719 i);
1720 }
1721 has_dynamic_vertex_input_binding_stride = true;
1722 }
1723 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1724 if (has_dynamic_depth_test_enable) {
1725 skip |= LogError(
1726 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1727 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1728 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1729 i);
1730 }
1731 has_dynamic_depth_test_enable = true;
1732 }
1733 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1734 if (has_dynamic_depth_write_enable) {
1735 skip |= LogError(
1736 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1737 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1738 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1739 i);
1740 }
1741 has_dynamic_depth_write_enable = true;
1742 }
1743 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1744 if (has_dynamic_depth_compare_op) {
1745 skip |=
1746 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1747 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1748 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1749 i);
1750 }
1751 has_dynamic_depth_compare_op = true;
1752 }
1753 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1754 if (has_dynamic_depth_bounds_test_enable) {
1755 skip |= LogError(
1756 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1757 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1758 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1759 i);
1760 }
1761 has_dynamic_depth_bounds_test_enable = true;
1762 }
1763 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1764 if (has_dynamic_stencil_test_enable) {
1765 skip |= LogError(
1766 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1767 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1768 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1769 i);
1770 }
1771 has_dynamic_stencil_test_enable = true;
1772 }
1773 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1774 if (has_dynamic_stencil_op) {
1775 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1776 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1777 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1778 i);
1779 }
1780 has_dynamic_stencil_op = true;
1781 }
Petr Kraus299ba622017-11-24 03:09:03 +01001782 }
1783 }
1784
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001785 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04001786 if ((feedback_struct != nullptr) &&
1787 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001788 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1789 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1790 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1791 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1792 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001793 }
1794
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001795 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001796
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001797 // Collect active stages and other information
1798 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001799 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001800 bool has_eval = false;
1801 bool has_control = false;
1802 if (pCreateInfos[i].pStages != nullptr) {
1803 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1804 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1805
1806 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1807 has_control = true;
1808 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1809 has_eval = true;
1810 }
1811
1812 skip |= validate_string(
1813 "vkCreateGraphicsPipelines",
1814 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1815 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1816 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001817 }
1818
1819 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1820 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1821 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1822 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1823 pCreateInfos[i].pTessellationState,
1824 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1825 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1826
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001827 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001828 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1829
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001830 skip |= validate_struct_pnext(
1831 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1832 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
1833 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
1834 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
1835 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1836 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001837
1838 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1839 pCreateInfos[i].pTessellationState->flags,
1840 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1841 }
1842
1843 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1844 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1845 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1846 pCreateInfos[i].pInputAssemblyState,
1847 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1848 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1849
1850 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1851 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001852 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001853
1854 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1855 pCreateInfos[i].pInputAssemblyState->flags,
1856 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1857
1858 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1859 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1860 pCreateInfos[i].pInputAssemblyState->topology,
1861 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1862
1863 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1864 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1865 }
1866
1867 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001868 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001869
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001870 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001871 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1872 "vkCreateGraphicsPipelines: pararameter "
1873 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1874 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001875 }
1876
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001877 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001878 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1879 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1880 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1881 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001882 allowed_structs_vk_pipeline_vertex_input_state_create_info,
1883 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08001884 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001885 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1886 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001887 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001888 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1889 skip |=
1890 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1891 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1892 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1893 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1894 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1895
1896 skip |= validate_array(
1897 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1898 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1899 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1900 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1901
1902 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001903 for (uint32_t vertex_binding_description_index = 0;
1904 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1905 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001906 skip |= validate_ranged_enum(
1907 "vkCreateGraphicsPipelines",
1908 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1909 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001910 pCreateInfos[i]
1911 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
1912 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001913 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1914 }
1915 }
1916
1917 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001918 for (uint32_t vertex_attribute_description_index = 0;
1919 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1920 ++vertex_attribute_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001921 skip |= validate_ranged_enum(
1922 "vkCreateGraphicsPipelines",
1923 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1924 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001925 pCreateInfos[i]
1926 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
1927 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001928 "VUID-VkVertexInputAttributeDescription-format-parameter");
1929 }
1930 }
1931
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001932 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001933 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1934 "vkCreateGraphicsPipelines: pararameter "
1935 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1936 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1937 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001938 }
1939
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001940 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001941 skip |=
1942 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1943 "vkCreateGraphicsPipelines: pararameter "
1944 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1945 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1946 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001947 }
1948
1949 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001950 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1951 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001952 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1953 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001954 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1955 "vkCreateGraphicsPipelines: parameter "
1956 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1957 "(%" PRIu32 ") is not distinct.",
1958 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001959 }
1960 vertex_bindings.insert(vertex_bind_desc.binding);
1961
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001962 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001963 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1964 "vkCreateGraphicsPipelines: parameter "
1965 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1966 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1967 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001968 }
1969
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001970 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001971 skip |=
1972 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1973 "vkCreateGraphicsPipelines: parameter "
1974 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1975 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1976 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001977 }
1978 }
1979
Peter Kohautc7d9d392018-07-15 00:34:07 +02001980 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001981 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1982 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001983 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1984 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001985 skip |= LogError(
1986 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001987 "vkCreateGraphicsPipelines: parameter "
1988 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1989 i, d, vertex_attrib_desc.location);
1990 }
1991 attribute_locations.insert(vertex_attrib_desc.location);
1992
1993 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1994 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001995 skip |= LogError(
1996 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001997 "vkCreateGraphicsPipelines: parameter "
1998 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1999 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
2000 i, d, vertex_attrib_desc.binding, i);
2001 }
2002
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002003 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002004 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2005 "vkCreateGraphicsPipelines: parameter "
2006 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
2007 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2008 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002009 }
2010
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002011 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002012 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2013 "vkCreateGraphicsPipelines: parameter "
2014 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
2015 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2016 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002017 }
2018
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002019 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002020 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2021 "vkCreateGraphicsPipelines: parameter "
2022 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
2023 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
2024 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002025 }
2026 }
2027 }
2028
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002029 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2030 if (has_control && has_eval) {
2031 if (pCreateInfos[i].pTessellationState == nullptr) {
2032 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
2033 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
2034 "shader stage and a tessellation evaluation shader stage, "
2035 "pCreateInfos[%d].pTessellationState must not be NULL.",
2036 i, i);
2037 } else {
2038 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2039 skip |= validate_struct_pnext(
2040 "vkCreateGraphicsPipelines",
2041 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2042 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2043 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2044 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002045
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002046 skip |= validate_reserved_flags(
2047 "vkCreateGraphicsPipelines",
2048 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2049 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002050
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002051 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2052 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2053 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2054 "vkCreateGraphicsPipelines: invalid parameter "
2055 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
2056 "should be >0 and <=%u.",
2057 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2058 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002059 }
2060 }
2061 }
2062
2063 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2064 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2065 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2066 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002067 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2068 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2069 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2070 "].pViewportState (=NULL) is not a valid pointer.",
2071 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002072 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002073 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2074
2075 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002076 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2077 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2078 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2079 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002080 }
2081
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002082 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002083 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002084 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2085 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002086 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2087 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002088 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002089 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002090 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002091 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002092 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002093 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2094 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002095 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2096 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2097 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002098 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002099
2100 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002101 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002102 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002103 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002104
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002105 auto exclusive_scissor_struct =
2106 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2107 auto shading_rate_image_struct =
2108 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2109 auto coarse_sample_order_struct =
2110 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002111 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002112 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002113 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002114 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002115
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002116 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002117 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002118 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2119 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2120 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2121 ") is not 1.",
2122 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002123 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002124
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002125 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002126 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2127 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2128 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2129 ") is not 1.",
2130 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002131 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002132
Dave Houlton142c4cb2018-10-17 15:04:41 -06002133 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2134 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002135 skip |= LogError(
2136 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2137 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2138 "disabled, but pCreateInfos[%" PRIu32
2139 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2140 ") is not 1.",
2141 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002142 }
2143
Jeff Bolz9af91c52018-09-01 21:53:57 -05002144 if (shading_rate_image_struct &&
2145 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002146 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2147 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2148 "disabled, but pCreateInfos[%" PRIu32
2149 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2150 ") is neither 0 nor 1.",
2151 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002152 }
2153
Petr Krausa6103552017-11-16 21:21:58 +01002154 } else { // multiViewport enabled
2155 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002156 if (!has_dynamic_viewport_with_count) {
2157 skip |= LogError(
2158 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2159 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2160 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002161 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002162 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2163 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2164 "].pViewportState->viewportCount (=%" PRIu32
2165 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2166 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002167 } else if (has_dynamic_viewport_with_count) {
2168 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2169 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2170 "].pViewportState->viewportCount (=%" PRIu32
2171 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2172 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002173 }
Petr Krausa6103552017-11-16 21:21:58 +01002174
2175 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002176 if (!has_dynamic_scissor_with_count) {
2177 skip |= LogError(
2178 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2179 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2180 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002181 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002182 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2183 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2184 "].pViewportState->scissorCount (=%" PRIu32
2185 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2186 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002187 } else if (has_dynamic_scissor_with_count) {
2188 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2189 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2190 "].pViewportState->scissorCount (=%" PRIu32
2191 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2192 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002193 }
2194 }
2195
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002196 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002197 skip |=
2198 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2199 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2200 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2201 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002202 }
2203
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002204 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002205 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2206 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2207 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2208 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2209 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002210 }
2211
Piers Daniell39842ee2020-07-10 16:42:33 -06002212 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2213 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002214 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2215 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2216 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2217 "].pViewportState->viewportCount (=%" PRIu32 ").",
2218 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002219 }
2220
Dave Houlton142c4cb2018-10-17 15:04:41 -06002221 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002222 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002223 skip |=
2224 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2225 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2226 ") must be zero or identical to pCreateInfos[%" PRIu32
2227 "].pViewportState->viewportCount (=%" PRIu32 ").",
2228 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002229 }
2230
Dave Houlton142c4cb2018-10-17 15:04:41 -06002231 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002232 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002233 skip |= LogError(
2234 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002235 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2236 "] "
2237 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2238 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2239 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002240 }
2241
Petr Krausa6103552017-11-16 21:21:58 +01002242 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002243 skip |= LogError(
2244 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002245 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2246 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002247 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2248 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002249 }
2250
2251 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002252 skip |= LogError(
2253 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002254 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2255 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002256 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2257 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002258 }
2259
Jeff Bolz3e71f782018-08-29 23:15:45 -05002260 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002261 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2262 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2263 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002264 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002265 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2266 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2267 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2268 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002269 }
2270
Jeff Bolz9af91c52018-09-01 21:53:57 -05002271 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002272 shading_rate_image_struct->viewportCount > 0 &&
2273 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002274 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002275 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002276 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002277 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2278 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002279 i, i);
2280 }
2281
Chris Mayer328d8212018-12-11 14:16:18 +01002282 if (vp_swizzle_struct) {
2283 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002284 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2285 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2286 " does "
2287 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2288 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002289 }
2290 }
2291
Petr Krausb3fcdb42018-01-09 22:09:09 +01002292 // validate the VkViewports
2293 if (!has_dynamic_viewport && viewport_state.pViewports) {
2294 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2295 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002296 const char *fn_name = "vkCreateGraphicsPipelines";
2297 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2298 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2299 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002300 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002301 }
2302 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002303
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002304 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002305 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2306 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2307 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2308 "VK_NV_clip_space_w_scaling extension is not enabled.",
2309 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002310 }
2311
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002312 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002313 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2314 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2315 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2316 "VK_EXT_discard_rectangles extension is not enabled.",
2317 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002318 }
2319
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002320 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002321 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2322 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2323 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2324 "VK_EXT_sample_locations extension is not enabled.",
2325 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002326 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002327
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002328 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002329 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2330 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2331 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2332 "VK_NV_scissor_exclusive extension is not enabled.",
2333 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002334 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002335
2336 if (coarse_sample_order_struct &&
2337 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2338 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002339 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2340 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2341 "] "
2342 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2343 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2344 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002345 }
2346
2347 if (coarse_sample_order_struct) {
2348 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002349 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002350 }
2351 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002352
2353 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2354 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002355 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2356 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2357 "] "
2358 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2359 ") "
2360 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2361 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002362 }
2363 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002364 skip |= LogError(
2365 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002366 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2367 "] "
2368 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2369 i);
2370 }
2371 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002372 }
2373
2374 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002375 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2376 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2377 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2378 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002379 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002380 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002381 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002382 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2383 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002384 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002385 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002386 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002387 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002388 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002389 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002390 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002391 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2392 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002393
2394 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002395 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002396 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002397 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002398
2399 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002400 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002401 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2402 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2403
2404 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002405 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002406 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2407 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002408 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002409 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002410
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002411 skip |= validate_flags(
2412 "vkCreateGraphicsPipelines",
2413 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2414 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002415 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002416
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002417 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002418 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002419 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2420 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2421
2422 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002423 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002424 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2425 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2426
2427 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002428 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002429 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2430 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2431 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002432 }
John Zulauf7acac592017-11-06 11:15:53 -07002433 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002434 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002435 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2436 "vkCreateGraphicsPipelines(): parameter "
2437 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2438 i);
John Zulauf7acac592017-11-06 11:15:53 -07002439 }
2440 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2441 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2442 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002443 skip |= LogError(
2444 device,
2445
Dave Houlton413a6782018-05-22 13:01:54 -06002446 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002447 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002448 }
2449 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002450
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002451 const auto *line_state =
2452 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002453
2454 if (line_state) {
2455 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2456 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2457 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2458 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002459 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2460 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2461 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2462 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002463 }
2464 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2465 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002466 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2467 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2468 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2469 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002470 }
2471 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2472 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002473 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2474 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2475 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2476 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002477 }
2478 }
2479 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2480 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2481 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002482 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2483 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2484 "range [1,256].",
2485 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002486 }
2487 }
2488 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002489 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002490 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2491 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002492 skip |=
2493 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2494 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2495 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2496 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002497 }
2498 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2499 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002500 skip |=
2501 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2502 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2503 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2504 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002505 }
2506 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2507 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002508 skip |=
2509 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2510 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2511 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2512 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002513 }
2514 if (line_state->stippledLineEnable) {
2515 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2516 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002517 skip |=
2518 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2519 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2520 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2521 "stippledRectangularLines feature.",
2522 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002523 }
2524 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2525 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002526 skip |=
2527 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2528 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2529 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2530 "stippledBresenhamLines feature.",
2531 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002532 }
2533 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2534 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002535 skip |=
2536 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2537 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2538 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2539 "stippledSmoothLines feature.",
2540 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002541 }
2542 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2543 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002544 skip |=
2545 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2546 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2547 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2548 "stippledRectangularLines and strictLines features.",
2549 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002550 }
2551 }
2552 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002553 }
2554
Petr Krause91f7a12017-12-14 20:57:36 +01002555 bool uses_color_attachment = false;
2556 bool uses_depthstencil_attachment = false;
2557 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002558 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002559 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2560 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002561 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002562 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002563 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002564 }
2565 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002566 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002567 }
Petr Krause91f7a12017-12-14 20:57:36 +01002568 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002569 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002570 }
2571
2572 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002573 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002574 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002575 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002576 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002577 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002578
2579 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002580 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002581 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002582 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002583
2584 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002585 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002586 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2587 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2588
2589 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002590 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002591 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2592 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2593
2594 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002595 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002596 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2597 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002598 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002599
2600 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002601 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002602 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2603 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2604
2605 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002606 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002607 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2608 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2609
2610 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002611 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002612 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2613 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002614 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002615
2616 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002617 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002618 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2619 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002620 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002621
2622 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002623 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002624 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2625 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002626 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002627
2628 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002629 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002630 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2631 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002632 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002633
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->back.failOp", ParameterName::IndexVector{i}),
2637 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002638 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002639
2640 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002641 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002642 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2643 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002644 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002645
2646 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002647 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002648 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2649 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002650 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002651
2652 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002653 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002654 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2655 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002656 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002657
2658 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002659 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002660 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2661 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2662 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002663 }
2664 }
2665
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002666 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002667 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2668
Petr Krause91f7a12017-12-14 20:57:36 +01002669 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002670 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2671 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2672 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2673 pCreateInfos[i].pColorBlendState,
2674 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2675 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2676
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002677 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002678 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002679 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2680 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002681 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2682 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002683 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2684 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002685
2686 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002687 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002688 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002689 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002690
2691 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002692 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002693 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2694 pCreateInfos[i].pColorBlendState->logicOpEnable);
2695
2696 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002697 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002698 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2699 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002700 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002701 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002702
2703 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002704 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
2705 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002706 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002707 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002708 ParameterName::IndexVector{i, attachment_index}),
2709 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002710
2711 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002712 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002713 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002714 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002715 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002716 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002717 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002718
2719 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002720 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002721 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002722 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002723 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002724 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002725 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002726
2727 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002728 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002729 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002730 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002731 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002732 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002733 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002734
2735 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002736 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002737 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002738 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002739 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002740 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002741 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002742
2743 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002744 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002745 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002746 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002747 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002748 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002749 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
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].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002754 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002755 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002756 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002757 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002758
2759 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002760 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002761 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002762 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002763 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002764 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002765 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002766 }
2767 }
2768
2769 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002770 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002771 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2772 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2773 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002774 }
2775
2776 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2777 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2778 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002779 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002780 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002781 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2782 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002783 }
2784 }
2785 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002786
Petr Kraus9752aae2017-11-24 03:05:50 +01002787 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2788 if (pCreateInfos[i].basePipelineIndex != -1) {
2789 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002790 skip |=
2791 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002792 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002793 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002794 "and pCreateInfos->basePipelineIndex is not -1.",
2795 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002796 }
2797 }
2798
Petr Kraus9752aae2017-11-24 03:05:50 +01002799 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2800 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002801 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002802 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002803 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002804 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2805 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002806 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002807 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002808 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002809 skip |=
2810 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2811 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2812 "index into the pCreateInfos array, of size %d.",
2813 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002814 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002815 }
2816 }
2817
sfricke-samsung898cf222020-05-15 23:10:19 -07002818 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2819 skip |= LogError(
2820 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2821 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE",
2822 i);
2823 }
2824
Petr Kraus9752aae2017-11-24 03:05:50 +01002825 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002826 if (!device_extensions.vk_nv_fill_rectangle) {
2827 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2828 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002829 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2830 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2831 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2832 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002833 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2834 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07002835 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002836 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002837 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2838 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2839 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002840 }
2841 } else {
2842 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2843 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2844 (physical_device_features.fillModeNonSolid == false)) {
2845 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002846 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2847 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002848 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2849 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2850 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002851 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002852 }
Petr Kraus299ba622017-11-24 03:09:03 +01002853
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002854 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002855 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002856 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2857 "The line width state is static (pCreateInfos[%" PRIu32
2858 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2859 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2860 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2861 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002862 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002863 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002864 }
2865 }
2866
2867 return skip;
2868}
2869
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002870bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2871 uint32_t createInfoCount,
2872 const VkComputePipelineCreateInfo *pCreateInfos,
2873 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002874 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002875 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002876 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002877 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002878 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002879 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002880 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04002881 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002882 skip |=
2883 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2884 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2885 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2886 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002887 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002888
2889 // Make sure compute stage is selected
2890 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002891 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2892 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2893 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002894 }
sourav parmarcd5fb182020-07-17 12:58:44 -07002895
2896 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
2897 skip |=
2898 LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
2899 "vkCreateComputePipelines(): flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR");
2900 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002901 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002902 return skip;
2903}
2904
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002905bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002906 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002907 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002908
2909 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002910 const auto &features = physical_device_features;
2911 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002912
John Zulauf71968502017-10-26 13:51:15 -06002913 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2914 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002915 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2916 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2917 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2918 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002919 }
2920
2921 // Anistropy cannot be enabled in sampler unless enabled as a feature
2922 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002923 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2924 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2925 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002926 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002927 }
John Zulauf71968502017-10-26 13:51:15 -06002928
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002929 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2930 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002931 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2932 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2933 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2934 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002935 }
2936 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002937 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2938 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2939 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2940 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002941 }
2942 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002943 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2944 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2945 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2946 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002947 }
2948 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2949 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2950 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2951 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002952 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2953 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2954 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2955 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2956 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2957 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002958 }
2959 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002960 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2961 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2962 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002963 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002964 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002965 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2966 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2967 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002968 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002969 }
2970
2971 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2972 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002973 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2974 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002975 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07002976 if (sampler_reduction != nullptr) {
2977 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
2978 skip |= LogError(
2979 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
2980 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
2981 }
2982 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002983 }
2984
2985 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2986 // valid VkBorderColor value
2987 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2988 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2989 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002990 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2991 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002992 }
2993
2994 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2995 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002996 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002997 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2998 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2999 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06003000 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003001 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
3002 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
3003 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003004 }
John Zulauf275805c2017-10-26 15:34:49 -06003005
3006 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003007 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06003008 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3009 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003010 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3011 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3012 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003013 }
3014 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003015
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003016 // Check for valid Lod range
3017 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003018 skip |=
3019 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3020 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003021 }
3022
3023 // Check mipLodBias to device limit
3024 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003025 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3026 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3027 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003028 }
3029
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003030 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003031 if (sampler_conversion != nullptr) {
3032 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3033 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3034 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3035 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003036 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003037 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003038 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3039 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3040 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3041 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3042 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3043 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3044 }
3045 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003046
3047 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3048 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3049 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3050 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3051 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3052 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3053 }
3054 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3055 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3056 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3057 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3058 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3059 }
3060 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3061 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3062 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3063 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3064 pCreateInfo->minLod, pCreateInfo->maxLod);
3065 }
3066 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3067 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3068 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3069 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3070 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3071 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3072 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3073 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3074 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3075 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3076 }
3077 if (pCreateInfo->anisotropyEnable) {
3078 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3079 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3080 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3081 }
3082 if (pCreateInfo->compareEnable) {
3083 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3084 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3085 "pCreateInfo->compareEnable must be VK_FALSE");
3086 }
3087 if (pCreateInfo->unnormalizedCoordinates) {
3088 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3089 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3090 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3091 }
3092 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003093 }
3094
Tony-LunarG7337b312020-04-15 16:40:25 -06003095 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3096 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3097 if (!device_extensions.vk_ext_custom_border_color) {
3098 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3099 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3100 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3101 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003102 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003103 if (!custom_create_info) {
3104 skip |=
3105 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3106 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3107 "struct in pNext chain.\n",
3108 string_VkBorderColor(pCreateInfo->borderColor));
3109 } else {
3110 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3111 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3112 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3113 !FormatIsSampledFloat(custom_create_info->format)))) {
3114 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3115 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3116 "whose type does not match\n",
3117 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3118 ;
3119 }
3120 }
3121 }
3122
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003123 return skip;
3124}
3125
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003126bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3127 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3128 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003129 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003130 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003131
3132 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3133 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3134 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3135 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003136 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3137 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3138 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3139 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3140 ++descriptor_index) {
3141 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003142 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003143 "vkCreateDescriptorSetLayout: required parameter "
3144 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3145 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003146 }
3147 }
3148 }
3149
3150 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3151 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3152 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003153 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3154 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3155 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3156 "values.",
3157 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003158 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003159
3160 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3161 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3162 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3163 skip |=
3164 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3165 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3166 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3167 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3168 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3169 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003170 }
3171 }
3172 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003173 return skip;
3174}
3175
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003176bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3177 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003178 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003179 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3180 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3181 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003182 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3183 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003184}
3185
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003186bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3187 const VkWriteDescriptorSet *pDescriptorWrites,
3188 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003189 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003190
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003191 if (pDescriptorWrites != NULL) {
3192 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3193 // descriptorCount must be greater than 0
3194 if (pDescriptorWrites[i].descriptorCount == 0) {
3195 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003196 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3197 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003198 }
3199
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003200 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3201 if (validateDstSet) {
3202 // dstSet must be a valid VkDescriptorSet handle
3203 skip |= validate_required_handle(vkCallingFunction,
3204 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3205 pDescriptorWrites[i].dstSet);
3206 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003207
3208 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3209 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3210 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3211 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3212 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3213 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3214 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003215 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3216 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003217 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003218 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3219 "%s(): if pDescriptorWrites[%d].descriptorType is "
3220 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3221 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3222 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3223 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003224 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3225 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003226 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3227 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003228 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3229 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003230 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003231 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3232 ParameterName::IndexVector{i, descriptor_index}),
3233 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003234 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003235 }
3236 }
3237 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3238 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3239 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3240 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3241 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3242 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3243 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003244 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003245 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003246 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3247 "%s(): if pDescriptorWrites[%d].descriptorType is "
3248 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3249 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3250 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3251 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003252 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003253 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003254 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003255 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003256 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3257 ++descriptor_index) {
3258 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3259 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3260 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003261 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3262 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003263 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003264 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3265 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003266 }
3267 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003268 }
3269 }
3270 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3271 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003272 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003273 }
3274
3275 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3276 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003277 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003278 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3279 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003280 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003281 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003282 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3283 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3284 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003285 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003286 }
3287 }
3288 }
3289 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3290 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003291 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003292 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3293 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003294 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003295 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003296 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3297 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3298 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003299 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003300 }
3301 }
3302 }
3303 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003304 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3305 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003306 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003307 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003308 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3309 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3310 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3311 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3312 "accelerationStructureCount %d member equals descriptorCount %d.",
3313 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3314 pDescriptorWrites[i].descriptorCount);
3315 }
3316 // further checks only if we have right structtype
3317 if (pnext_struct) {
3318 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3319 skip |= LogError(
3320 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3321 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3322 ".",
3323 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003324 }
sourav parmarbcee7512020-12-28 14:34:49 -08003325 if (pnext_struct->accelerationStructureCount == 0) {
3326 skip |= LogError(device,
3327 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
3328 "%s(): accelerationStructureCount must be greater than 0 .");
3329 }
3330 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003331 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003332 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3333 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3334 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3335 skip |= LogError(device,
3336 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3337 "%s(): If the nullDescriptor feature is not enabled, each member of "
3338 "pAccelerationStructures must not be VK_NULL_HANDLE.");
sourav parmarcd5fb182020-07-17 12:58:44 -07003339 }
3340 }
3341 }
sourav parmarbcee7512020-12-28 14:34:49 -08003342 }
3343 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003344 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003345 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3346 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3347 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3348 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3349 "accelerationStructureCount %d member equals descriptorCount %d.",
3350 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3351 pDescriptorWrites[i].descriptorCount);
3352 }
3353 // further checks only if we have right structtype
3354 if (pnext_struct) {
3355 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3356 skip |= LogError(
3357 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3358 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3359 ".",
3360 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003361 }
sourav parmarbcee7512020-12-28 14:34:49 -08003362 if (pnext_struct->accelerationStructureCount == 0) {
3363 skip |= LogError(device,
3364 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
3365 "%s(): accelerationStructureCount must be greater than 0 .");
3366 }
3367 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003368 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003369 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3370 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3371 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3372 skip |= LogError(device,
3373 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3374 "%s(): If the nullDescriptor feature is not enabled, each member of "
3375 "pAccelerationStructures must not be VK_NULL_HANDLE.");
sourav parmarcd5fb182020-07-17 12:58:44 -07003376 }
3377 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003378 }
3379 }
3380 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003381 }
3382 }
3383 return skip;
3384}
3385
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003386bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3387 const VkWriteDescriptorSet *pDescriptorWrites,
3388 uint32_t descriptorCopyCount,
3389 const VkCopyDescriptorSet *pDescriptorCopies) const {
3390 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3391}
3392
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003393bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003394 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003395 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003396 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3397}
3398
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003399bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3400 const VkAllocationCallbacks *pAllocator,
3401 VkRenderPass *pRenderPass) const {
3402 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3403}
3404
Mike Schuchardt2df08912020-12-15 16:28:09 -08003405bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003406 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003407 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003408 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3409}
3410
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003411bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3412 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003413 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003414 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003415
3416 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3417 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3418 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003419 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3420 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003421 return skip;
3422}
3423
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003424bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003425 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003426 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003427
3428 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3429 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003430 bool cb_is_secondary;
3431 {
3432 auto lock = cb_read_lock();
3433 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3434 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003435
Tony-LunarG3c287f62020-12-17 12:39:49 -07003436 if (cb_is_secondary) {
3437 // Implicit VUs
3438 // validate only sType here; pointer has to be validated in core_validation
3439 const bool k_not_required = false;
3440 const char *k_no_vuid = nullptr;
3441 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3442 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003443 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3444 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003445
Tony-LunarG3c287f62020-12-17 12:39:49 -07003446 if (info) {
3447 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003448 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003449 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003450 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3451 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3452 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3453 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003454
Tony-LunarG3c287f62020-12-17 12:39:49 -07003455 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003456
Tony-LunarG3c287f62020-12-17 12:39:49 -07003457 // Explicit VUs
3458 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003459 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003460 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3461 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3462 cmd_name);
3463 }
3464
3465 if (physical_device_features.inheritedQueries) {
3466 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003467 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3468 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3469 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003470 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003471 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003472 }
3473
3474 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003475 skip |=
3476 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
3477 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
3478 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
3479 } else { // !pipelineStatisticsQuery
3480 skip |=
3481 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
3482 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003483 }
3484
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003485 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003486 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003487 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003488 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3489 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
3490 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003491 commandBuffer,
3492 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07003493 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3494 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3495 }
Petr Kraus139757b2019-08-15 17:19:33 +02003496 }
3497 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003498 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003499 return skip;
3500}
3501
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003502bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003503 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003504 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003505
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003506 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003507 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003508 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3509 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3510 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003511 }
3512 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003513 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3514 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3515 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003516 }
3517 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003518 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003519 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003520 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3521 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3522 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3523 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003524 }
3525 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003526
3527 if (pViewports) {
3528 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3529 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003530 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003531 skip |= manual_PreCallValidateViewport(
3532 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003533 }
3534 }
3535
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003536 return skip;
3537}
3538
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003539bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003540 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003541 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003542
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003543 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003544 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003545 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3546 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3547 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003548 }
3549 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003550 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3551 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3552 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003553 }
3554 } else { // multiViewport enabled
3555 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003556 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003557 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3558 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3559 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3560 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003561 }
3562 }
3563
Petr Kraus6260f0a2018-02-27 21:15:55 +01003564 if (pScissors) {
3565 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3566 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003567
Petr Kraus6260f0a2018-02-27 21:15:55 +01003568 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003569 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3570 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3571 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003572 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003573
Petr Kraus6260f0a2018-02-27 21:15:55 +01003574 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003575 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3576 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3577 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003578 }
3579
3580 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3581 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003582 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3583 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3584 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3585 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003586 }
3587
3588 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3589 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003590 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3591 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3592 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3593 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003594 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003595 }
3596 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003597
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003598 return skip;
3599}
3600
Jeff Bolz5c801d12019-10-09 10:38:45 -05003601bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003602 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003603
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003604 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003605 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3606 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003607 }
3608
3609 return skip;
3610}
3611
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003612bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003613 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003614 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003615
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003616 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003617 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003618 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
3619 }
3620 if (drawCount > device_limits.maxDrawIndirectCount) {
3621 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003622 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
3623 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003624 }
3625 return skip;
3626}
3627
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003628bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003629 VkDeviceSize offset, uint32_t drawCount,
3630 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003631 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003632 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003633 skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
3634 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
3635 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003636 }
3637 if (drawCount > device_limits.maxDrawIndirectCount) {
3638 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003639 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).",
3640 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003641 }
3642 return skip;
3643}
3644
sfricke-samsungf692b972020-05-02 08:00:45 -07003645bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3646 VkDeviceSize countBufferOffset, bool khr) const {
3647 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003648 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003649 if (offset & 3) {
3650 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003651 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003652 }
3653
3654 if (countBufferOffset & 3) {
3655 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003656 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003657 countBufferOffset);
3658 }
3659 return skip;
3660}
3661
3662bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3663 VkDeviceSize offset, VkBuffer countBuffer,
3664 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3665 uint32_t stride) const {
3666 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3667}
3668
3669bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3670 VkDeviceSize offset, VkBuffer countBuffer,
3671 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3672 uint32_t stride) const {
3673 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3674}
3675
3676bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3677 VkDeviceSize countBufferOffset, bool khr) const {
3678 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003679 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003680 if (offset & 3) {
3681 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003682 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003683 }
3684
3685 if (countBufferOffset & 3) {
3686 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003687 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003688 countBufferOffset);
3689 }
3690 return skip;
3691}
3692
3693bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3694 VkDeviceSize offset, VkBuffer countBuffer,
3695 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3696 uint32_t stride) const {
3697 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3698}
3699
3700bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3701 VkDeviceSize offset, VkBuffer countBuffer,
3702 VkDeviceSize countBufferOffset,
3703 uint32_t maxDrawCount, uint32_t stride) const {
3704 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3705}
3706
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003707bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3708 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003709 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003710 bool skip = false;
3711 for (uint32_t rect = 0; rect < rectCount; rect++) {
3712 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003713 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3714 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003715 }
sfricke-samsung10867682020-04-25 02:20:39 -07003716 if (pRects[rect].rect.extent.width == 0) {
3717 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3718 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3719 }
3720 if (pRects[rect].rect.extent.height == 0) {
3721 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3722 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3723 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003724 }
3725 return skip;
3726}
3727
Andrew Fobel3abeb992020-01-20 16:33:22 -05003728bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3729 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3730 VkImageFormatProperties2 *pImageFormatProperties,
3731 const char *apiName) const {
3732 bool skip = false;
3733
3734 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003735 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003736 if (image_stencil_struct != nullptr) {
3737 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3738 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3739 // No flags other than the legal attachment bits may be set
3740 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3741 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003742 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3743 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3744 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3745 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3746 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003747 }
3748 }
3749 }
3750 }
3751
3752 return skip;
3753}
3754
3755bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3756 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3757 VkImageFormatProperties2 *pImageFormatProperties) const {
3758 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3759 "vkGetPhysicalDeviceImageFormatProperties2");
3760}
3761
3762bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3763 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3764 VkImageFormatProperties2 *pImageFormatProperties) const {
3765 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3766 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3767}
3768
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03003769bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
3770 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
3771 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
3772 bool skip = false;
3773
3774 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
3775 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
3776 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
3777 }
3778
3779 return skip;
3780}
3781
sfricke-samsung3999ef62020-02-09 17:05:59 -08003782bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3783 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3784 bool skip = false;
3785
3786 if (pRegions != nullptr) {
3787 for (uint32_t i = 0; i < regionCount; i++) {
3788 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003789 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3790 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003791 }
3792 }
3793 }
3794 return skip;
3795}
3796
Jeff Leger178b1e52020-10-05 12:22:23 -04003797bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
3798 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
3799 bool skip = false;
3800
3801 if (pCopyBufferInfo->pRegions != nullptr) {
3802 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
3803 if (pCopyBufferInfo->pRegions[i].size == 0) {
3804 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
3805 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
3806 }
3807 }
3808 }
3809 return skip;
3810}
3811
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003812bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003813 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3814 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003815 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003816
3817 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003818 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3819 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3820 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003821 }
3822
3823 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003824 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3825 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3826 "), must be greater than zero and less than or equal to 65536.",
3827 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003828 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003829 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3830 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3831 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003832 }
3833 return skip;
3834}
3835
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003836bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003837 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003838 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003839
3840 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003841 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3842 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3843 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003844 }
3845
3846 if (size != VK_WHOLE_SIZE) {
3847 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003848 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003849 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3850 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003851 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003852 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3853 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003854 }
3855 }
3856 return skip;
3857}
3858
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003859bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003860 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003861 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003862 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003863
3864 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003865 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3866 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3867 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3868 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003869 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3870 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3871 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003872 }
3873
3874 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3875 // queueFamilyIndexCount uint32_t values
3876 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003877 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3878 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3879 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3880 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003881 }
3882 }
3883
Dave Houlton413a6782018-05-22 13:01:54 -06003884 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003885 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003886 }
3887
3888 return skip;
3889}
3890
Jeff Bolz5c801d12019-10-09 10:38:45 -05003891bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003892 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003893
3894 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003895 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06003896 if (present_regions) {
3897 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003898 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003899 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3900 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07003901 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003902 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3903 "extension swapchainCount is %i. These values must be equal.",
3904 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003905 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003906 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003907 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3908 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003909 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3910 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3911 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003912 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003913 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003914 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003915 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003916 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003917 }
3918 }
3919
3920 return skip;
3921}
3922
sfricke-samsung5c1b7392020-12-13 22:17:15 -08003923bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
3924 const VkDisplayModeCreateInfoKHR *pCreateInfo,
3925 const VkAllocationCallbacks *pAllocator,
3926 VkDisplayModeKHR *pMode) const {
3927 bool skip = false;
3928
3929 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
3930 if (display_mode_parameters.visibleRegion.width == 0) {
3931 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
3932 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
3933 }
3934 if (display_mode_parameters.visibleRegion.height == 0) {
3935 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
3936 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
3937 }
3938 if (display_mode_parameters.refreshRate == 0) {
3939 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
3940 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
3941 }
3942
3943 return skip;
3944}
3945
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003946#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003947bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3948 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3949 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003950 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003951 bool skip = false;
3952
3953 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003954 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3955 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003956 }
3957
3958 return skip;
3959}
3960#endif // VK_USE_PLATFORM_WIN32_KHR
3961
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003962bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003963 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003964 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003965 bool skip = false;
3966
3967 if (pCreateInfo) {
3968 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003969 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3970 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003971 }
3972
3973 if (pCreateInfo->pPoolSizes) {
3974 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3975 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003976 skip |= LogError(
3977 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003978 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003979 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003980 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3981 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003982 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3983 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3984 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3985 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3986 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003987 }
Petr Krausc8655be2017-09-27 18:56:51 +02003988 }
3989 }
3990 }
3991
3992 return skip;
3993}
3994
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003995bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003996 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003997 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003998
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003999 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004000 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004001 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4002 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4003 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004004 }
4005
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004006 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004007 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004008 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4009 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4010 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004011 }
4012
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004013 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004014 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004015 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4016 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4017 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004018 }
4019
4020 return skip;
4021}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004022
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004023bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004024 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004025 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004026
4027 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004028 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
4029 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07004030 }
4031 return skip;
4032}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004033
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004034bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4035 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004036 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004037 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004038
4039 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004040 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004041 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004042 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4043 "vkCmdDispatch(): baseGroupX (%" PRIu32
4044 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4045 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004046 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004047 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4048 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4049 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4050 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004051 }
4052
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004053 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004054 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004055 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4056 "vkCmdDispatch(): baseGroupY (%" PRIu32
4057 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4058 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004059 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004060 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4061 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4062 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4063 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004064 }
4065
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004066 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004067 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004068 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4069 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4070 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4071 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004072 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004073 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4074 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4075 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4076 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004077 }
4078
4079 return skip;
4080}
4081
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004082bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4083 VkPipelineBindPoint pipelineBindPoint,
4084 VkPipelineLayout layout, uint32_t set,
4085 uint32_t descriptorWriteCount,
4086 const VkWriteDescriptorSet *pDescriptorWrites) const {
4087 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4088}
4089
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004090bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4091 uint32_t firstExclusiveScissor,
4092 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004093 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004094 bool skip = false;
4095
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004096 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004097 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004098 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004099 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4100 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4101 ") is not 0.",
4102 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004103 }
4104 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004105 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004106 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4107 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4108 ") is not 1.",
4109 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004110 }
4111 } else { // multiViewport enabled
4112 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004113 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004114 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4115 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4116 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4117 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004118 }
4119 }
4120
Jeff Bolz3e71f782018-08-29 23:15:45 -05004121 if (pExclusiveScissors) {
4122 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4123 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4124
4125 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004126 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4127 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4128 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004129 }
4130
4131 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004132 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4133 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4134 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004135 }
4136
4137 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4138 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004139 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4140 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4141 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4142 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004143 }
4144
4145 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4146 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004147 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4148 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4149 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4150 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004151 }
4152 }
4153 }
4154
4155 return skip;
4156}
4157
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004158bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4159 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004160 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004161 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004162 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4163 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4164 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4165 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4166 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4167 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004168 }
4169
4170 return skip;
4171}
4172
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004173bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4174 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004175 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004176 bool skip = false;
4177
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004178 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004179 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004180 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004181 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4182 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4183 ") is not 0.",
4184 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004185 }
4186 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004187 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004188 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4189 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4190 ") is not 1.",
4191 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004192 }
4193 }
4194
Jeff Bolz9af91c52018-09-01 21:53:57 -05004195 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004196 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004197 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4198 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4199 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4200 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004201 }
4202
4203 return skip;
4204}
4205
Jeff Bolz5c801d12019-10-09 10:38:45 -05004206bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4207 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4208 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004209 bool skip = false;
4210
Dave Houlton142c4cb2018-10-17 15:04:41 -06004211 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004212 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4213 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4214 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004215 }
4216
4217 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004218 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004219 }
4220
4221 return skip;
4222}
4223
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004224bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004225 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004226 bool skip = false;
4227
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004228 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004229 skip |= LogError(
4230 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004231 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4232 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004233 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004234 }
4235
4236 return skip;
4237}
4238
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004239bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4240 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004241 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004242 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004243 static const int condition_multiples = 0b0011;
4244 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004245 skip |= LogError(
4246 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004247 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004248 }
Lockee1c22882019-06-10 16:02:54 -06004249 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004250 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4251 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4252 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4253 stride);
Lockee1c22882019-06-10 16:02:54 -06004254 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004255 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004256 skip |= LogError(
4257 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4258 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004259 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004260 if (drawCount > device_limits.maxDrawIndirectCount) {
4261 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004262 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4263 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004264 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004265 return skip;
4266}
4267
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004268bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4269 VkDeviceSize offset, VkBuffer countBuffer,
4270 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004271 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004272 bool skip = false;
4273
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004274 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004275 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4276 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4277 "), is not a multiple of 4.",
4278 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004279 }
4280
4281 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004282 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4283 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4284 "), is not a multiple of 4.",
4285 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004286 }
4287
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004288 return skip;
4289}
4290
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004291bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004292 const VkAllocationCallbacks *pAllocator,
4293 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004294 bool skip = false;
4295
4296 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4297 if (pCreateInfo != nullptr) {
4298 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4299 // VkQueryPipelineStatisticFlagBits values
4300 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4301 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004302 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4303 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4304 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4305 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004306 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004307 if (pCreateInfo->queryCount == 0) {
4308 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4309 "vkCreateQueryPool(): queryCount must be greater than zero.");
4310 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004311 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004312 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004313}
4314
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004315bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4316 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004317 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004318 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4319 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004320}
4321
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004322void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004323 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4324 VkResult result) {
4325 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004326 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004327}
4328
Mike Schuchardt2df08912020-12-15 16:28:09 -08004329void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004330 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4331 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004332 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004333 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004334 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004335}
4336
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004337void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4338 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004339 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004340 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004341 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004342}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004343
Tony-LunarG3c287f62020-12-17 12:39:49 -07004344void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004345 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004346 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
4347 auto lock = cb_write_lock();
4348 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004349 secondary_cb_map.insert({pCommandBuffers[cb_index], pAllocateInfo->commandPool});
Tony-LunarG3c287f62020-12-17 12:39:49 -07004350 }
4351 }
4352}
4353
4354void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004355 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004356 auto lock = cb_write_lock();
4357 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
4358 secondary_cb_map.erase(pCommandBuffers[cb_index]);
4359 }
4360}
4361
4362void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004363 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004364 auto lock = cb_write_lock();
4365 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
4366 if (item->second == commandPool) {
4367 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004368 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004369 ++item;
4370 }
4371 }
4372}
4373
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004374bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004375 const VkAllocationCallbacks *pAllocator,
4376 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004377 bool skip = false;
4378
4379 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004380 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004381 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004382 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4383 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004384 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004385
4386 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004387 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004388 if (flags_info) {
4389 flags = flags_info->flags;
4390 }
4391
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004392 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004393 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08004394 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004395 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4396 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08004397 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004398 }
4399
4400#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004401 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004402#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004403 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4404 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004405#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004406 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004407#endif
4408
4409 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004410 skip |= LogError(
4411 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004412 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4413 }
4414 if (
4415#ifdef VK_USE_PLATFORM_WIN32_KHR
4416 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4417#endif
4418 (import_memory_fd && import_memory_fd->handleType) ||
4419#ifdef VK_USE_PLATFORM_ANDROID_KHR
4420 (import_memory_ahb && import_memory_ahb->buffer) ||
4421#endif
4422 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004423 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4424 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004425 }
4426 }
4427
4428 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004429 VkBool32 capture_replay = false;
4430 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004431 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004432 if (vulkan_12_features) {
4433 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4434 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4435 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004436 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004437 if (bda_features) {
4438 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4439 buffer_device_address = bda_features->bufferDeviceAddress;
4440 }
4441 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004442 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004443 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004444 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004445 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004446 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004447 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004448 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004449 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004450 }
4451 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004452 }
4453 return skip;
4454}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004455
Jason Macnak192fa0e2019-07-26 15:07:16 -07004456bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004457 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004458 bool skip = false;
4459
4460 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4461 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4462 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004463 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004464 } else {
4465 uint32_t vertex_component_size = 0;
4466 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4467 vertex_component_size = 4;
4468 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4469 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4470 vertex_component_size = 2;
4471 }
4472 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004473 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004474 }
4475 }
4476
4477 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4478 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004479 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004480 } else {
4481 uint32_t index_element_size = 0;
4482 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4483 index_element_size = 4;
4484 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4485 index_element_size = 2;
4486 }
4487 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004488 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004489 }
4490 }
4491 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4492 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004493 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004494 }
4495 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004496 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004497 }
4498 }
4499
4500 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004501 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004502 }
4503
4504 return skip;
4505}
4506
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004507bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4508 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004509 bool skip = false;
4510
4511 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004512 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004513 }
4514 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004515 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004516 }
4517
4518 return skip;
4519}
4520
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004521bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4522 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004523 bool skip = false;
4524 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004525 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004526 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004527 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004528 }
4529 return skip;
4530}
4531
4532bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004533 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004534 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004535 bool skip = false;
4536 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004537 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4538 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4539 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004540 }
4541 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004542 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4543 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4544 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004545 }
4546 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4547 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004548 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4549 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4550 "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 -07004551 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004552 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004553 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004554 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4555 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004556 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4557 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004558 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004559 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004560 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4561 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4562 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004563 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004564 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004565 uint64_t total_triangle_count = 0;
4566 for (uint32_t i = 0; i < info.geometryCount; i++) {
4567 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004568
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004569 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004570
Jason Macnak5c954952019-07-09 15:46:12 -07004571 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4572 continue;
4573 }
4574 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4575 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004576 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004577 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4578 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4579 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004580 }
4581 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004582 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4583 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4584 for (uint32_t i = 1; i < info.geometryCount; i++) {
4585 const VkGeometryNV &geometry = info.pGeometries[i];
4586 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004587 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004588 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4589 "info.pGeometries[0].geometryType.",
4590 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004591 }
4592 }
4593 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004594 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4595 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4596 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4597 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4598 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4599 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4600 }
4601 }
4602 skip |=
4603 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004604 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004605 return skip;
4606}
4607
Ricardo Garciaa4935972019-02-21 17:43:18 +01004608bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4609 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004610 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004611 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004612 if (pCreateInfo) {
4613 if ((pCreateInfo->compactedSize != 0) &&
4614 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004615 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4616 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4617 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4618 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004619 }
Jason Macnak5c954952019-07-09 15:46:12 -07004620
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004621 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004622 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004623 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004624 return skip;
4625}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004626
Jeff Bolz5c801d12019-10-09 10:38:45 -05004627bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4628 const VkAccelerationStructureInfoNV *pInfo,
4629 VkBuffer instanceData, VkDeviceSize instanceOffset,
4630 VkBool32 update, VkAccelerationStructureNV dst,
4631 VkAccelerationStructureNV src, VkBuffer scratch,
4632 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004633 bool skip = false;
4634
4635 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004636 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004637 }
4638
4639 return skip;
4640}
4641
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004642bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4643 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4644 VkAccelerationStructureKHR *pAccelerationStructure) const {
4645 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07004646 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004647 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07004648 if (!acceleration_structure_features ||
4649 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
4650 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
4651 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
4652 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004653 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004654 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
4655 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004656 (acceleration_structure_features &&
4657 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07004658 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07004659 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
4660 "vkCreateAccelerationStructureKHR(): If createFlags includes "
4661 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
4662 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07004663 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004664 if (pCreateInfo->deviceAddress &&
4665 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
4666 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
4667 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
4668 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
4669 }
4670 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
4671 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
4672 "vkCreateAccelerationStructureKHR(): offset must be a multiple of 256 bytes", pCreateInfo->offset);
4673 }
sourav parmar83c31b12020-05-06 12:30:54 -07004674 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004675 return skip;
4676}
4677
Jason Macnak5c954952019-07-09 15:46:12 -07004678bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4679 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004680 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004681 bool skip = false;
4682 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004683 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4684 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004685 }
4686 return skip;
4687}
4688
sourav parmarcd5fb182020-07-17 12:58:44 -07004689bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
4690 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
4691 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
4692 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07004693 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004694 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-03432",
4695 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07004696 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07004697 }
4698 return skip;
4699}
4700
Peter Chen85366392019-05-14 15:20:11 -04004701bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4702 uint32_t createInfoCount,
4703 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4704 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004705 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004706 bool skip = false;
4707
4708 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004709 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04004710 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004711 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004712 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4713 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4714 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4715 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004716 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004717
4718 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004719 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07004720 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4721 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4722 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4723 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4724 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4725 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4726 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4727 }
4728 }
4729
sourav parmarf4a78252020-04-10 13:04:21 -07004730 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4731 skip |=
4732 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4733 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4734 }
4735 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4736 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4737 skip |=
4738 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4739 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4740 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4741 }
4742 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4743 if (pCreateInfos[i].basePipelineIndex != -1) {
4744 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4745 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4746 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4747 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4748 "and pCreateInfos->basePipelineIndex is not -1.");
4749 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004750 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004751 skip |=
4752 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
4753 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
4754 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
4755 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
4756 "that element.");
4757 }
sourav parmarf4a78252020-04-10 13:04:21 -07004758 }
4759 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004760 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004761 skip |=
4762 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4763 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4764 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4765 "commands pCreateInfos parameter.");
4766 }
4767 } else {
4768 if (pCreateInfos[i].basePipelineIndex != -1) {
4769 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4770 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4771 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4772 }
4773 }
4774 }
4775 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4776 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4777 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4778 }
4779 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4780 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4781 "vkCreateRayTracingPipelinesNV: flags must not include "
4782 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4783 }
4784 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4785 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4786 "vkCreateRayTracingPipelinesNV: flags must not include "
4787 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4788 }
4789 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4790 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4791 "vkCreateRayTracingPipelinesNV: flags must not include "
4792 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4793 }
4794 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4795 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4796 "vkCreateRayTracingPipelinesNV: flags must not include "
4797 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4798 }
4799 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4800 skip |= LogError(
4801 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4802 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4803 }
4804 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4805 skip |= LogError(
4806 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4807 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4808 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004809 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
4810 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
4811 "vkCreateRayTracingPipelinesNV: flags must not include "
4812 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
4813 }
4814 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
4815 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
4816 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
4817 }
Peter Chen85366392019-05-14 15:20:11 -04004818 }
4819
4820 return skip;
4821}
4822
sourav parmarcd5fb182020-07-17 12:58:44 -07004823bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
4824 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
4825 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004826 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004827 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07004828 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
4829 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
4830 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07004831 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004832 for (uint32_t i = 0; i < createInfoCount; i++) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004833 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
4834 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4835 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
4836 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
4837 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4838 }
4839 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4840 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
4841 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
4842 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
4843 }
4844 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004845 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004846 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4847 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07004848 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
4849 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
4850 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004851 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4852 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4853 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004854 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004855 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07004856 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4857 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4858 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4859 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07004860 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07004861 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4862 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4863 }
4864 }
sourav parmarf4a78252020-04-10 13:04:21 -07004865 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004866 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4867 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07004868 }
4869 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004870 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07004871 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07004872 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
4873 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004874 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004875 }
4876 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
4877 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
4878 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07004879 }
4880 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4881 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4882 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4883 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4884 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4885 skip |= LogError(
4886 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07004887 "vkCreateRayTracingPipelinesKHR: If flags includes "
4888 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07004889 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4890 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4891 "must not be VK_SHADER_UNUSED_KHR");
4892 }
4893 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4894 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4895 skip |= LogError(
4896 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07004897 "vkCreateRayTracingPipelinesKHR: If flags includes "
4898 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07004899 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4900 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4901 "element must not be VK_SHADER_UNUSED_KHR");
4902 }
4903 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004904 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
4905 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
4906 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
4907 skip |= LogError(
4908 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
4909 "vkCreateRayTracingPipelinesKHR: If "
4910 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
4911 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
4912 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
4913 }
4914 }
sourav parmarf4a78252020-04-10 13:04:21 -07004915 }
4916 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4917 if (pCreateInfos[i].basePipelineIndex != -1) {
4918 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4919 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07004920 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07004921 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4922 "and pCreateInfos->basePipelineIndex is not -1.");
4923 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004924 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004925 skip |=
4926 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
4927 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
4928 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
4929 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
4930 "element.");
4931 }
sourav parmarf4a78252020-04-10 13:04:21 -07004932 }
4933 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004934 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004935 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07004936 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07004937 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4938 "commands pCreateInfos parameter %d.",
4939 pCreateInfos[i].basePipelineIndex, createInfoCount);
4940 }
4941 } else {
4942 if (pCreateInfos[i].basePipelineIndex != -1) {
4943 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07004944 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07004945 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4946 }
4947 }
4948 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004949 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
4950 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
4951 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
4952 "vkCreateRayTracingPipelinesKHR: If flags includes "
4953 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
4954 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004955 }
4956 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
4957 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
4958 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
4959 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
4960 "pLibraryInfo and pLibraryInterface must be NULL.");
4961 }
4962 if (pCreateInfos[i].pLibraryInfo) {
4963 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
4964 if (pCreateInfos[i].stageCount == 0) {
4965 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
4966 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
4967 "stageCount must not be 0.");
4968 }
4969 if (pCreateInfos[i].groupCount == 0) {
4970 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
4971 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
4972 "groupCount must not be 0.");
4973 }
4974 } else {
4975 if (pCreateInfos[i].pLibraryInterface == NULL) {
4976 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
4977 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
4978 "is greater than 0, its "
4979 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07004980 }
4981 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004982 }
4983 if (pCreateInfos[i].pLibraryInterface) {
4984 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
4985 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
4986 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
4987 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
4988 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
4989 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004990 }
4991 if (deferredOperation != VK_NULL_HANDLE) {
4992 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
4993 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
4994 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
4995 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07004996 }
4997 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004998 }
4999
5000 return skip;
5001}
5002
Mike Schuchardt21638df2019-03-16 10:52:02 -07005003#ifdef VK_USE_PLATFORM_WIN32_KHR
5004bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
5005 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005006 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07005007 bool skip = false;
5008 if (!device_extensions.vk_khr_swapchain)
5009 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
5010 if (!device_extensions.vk_khr_get_surface_capabilities_2)
5011 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
5012 if (!device_extensions.vk_khr_surface)
5013 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
5014 if (!device_extensions.vk_khr_get_physical_device_properties_2)
5015 skip |=
5016 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
5017 if (!device_extensions.vk_ext_full_screen_exclusive)
5018 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
5019 skip |= validate_struct_type(
5020 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
5021 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
5022 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
5023 if (pSurfaceInfo != NULL) {
5024 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
5025 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
5026 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
5027
5028 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
5029 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
5030 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5031 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005032 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5033 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005034
5035 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5036 }
5037 return skip;
5038}
5039#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005040
5041bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5042 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005043 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005044 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5045 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005046 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005047 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5048 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5049 }
5050 return skip;
5051}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005052
5053bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005054 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005055 bool skip = false;
5056
5057 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005058 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
5059 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005060 }
5061
5062 return skip;
5063}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005064
5065bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005066 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005067 bool skip = false;
5068
5069 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005070 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5071 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005072 }
5073
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005074 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005075 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005076 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5077 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005078 }
5079
5080 return skip;
5081}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005082
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005083bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5084 uint32_t bindingCount, const VkBuffer *pBuffers,
5085 const VkDeviceSize *pOffsets) const {
5086 bool skip = false;
5087 if (firstBinding > device_limits.maxVertexInputBindings) {
5088 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5089 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
5090 device_limits.maxVertexInputBindings);
5091 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5092 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
5093 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5094 "maxVertexInputBindings (%u)",
5095 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5096 }
5097
Jeff Bolz165818a2020-05-08 11:19:03 -05005098 for (uint32_t i = 0; i < bindingCount; ++i) {
5099 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005100 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005101 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5102 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5103 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5104 } else {
5105 if (pOffsets[i] != 0) {
5106 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5107 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5108 }
5109 }
5110 }
5111 }
5112
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005113 return skip;
5114}
5115
Mark Lobodzinski84988402019-09-11 15:27:30 -06005116bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005117 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005118 bool skip = false;
5119 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005120 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5121 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005122 }
5123 return skip;
5124}
5125
5126bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005127 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005128 bool skip = false;
5129 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005130 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5131 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005132 }
5133 return skip;
5134}
Petr Kraus3d720392019-11-13 02:52:39 +01005135
5136bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5137 VkSemaphore semaphore, VkFence fence,
5138 uint32_t *pImageIndex) const {
5139 bool skip = false;
5140
5141 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005142 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5143 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005144 }
5145
5146 return skip;
5147}
5148
5149bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5150 uint32_t *pImageIndex) const {
5151 bool skip = false;
5152
5153 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005154 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5155 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005156 }
5157
5158 return skip;
5159}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005160
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005161bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5162 uint32_t firstBinding, uint32_t bindingCount,
5163 const VkBuffer *pBuffers,
5164 const VkDeviceSize *pOffsets,
5165 const VkDeviceSize *pSizes) const {
5166 bool skip = false;
5167
5168 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5169 for (uint32_t i = 0; i < bindingCount; ++i) {
5170 if (pOffsets[i] & 3) {
5171 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5172 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5173 }
5174 }
5175
5176 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5177 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5178 "%s: The firstBinding(%" PRIu32
5179 ") index is greater than or equal to "
5180 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5181 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5182 }
5183
5184 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5185 skip |=
5186 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5187 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5188 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5189 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5190 }
5191
5192 for (uint32_t i = 0; i < bindingCount; ++i) {
5193 // pSizes is optional and may be nullptr.
5194 if (pSizes != nullptr) {
5195 if (pSizes[i] != VK_WHOLE_SIZE &&
5196 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5197 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5198 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5199 ") is not VK_WHOLE_SIZE and is greater than "
5200 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5201 cmd_name, i, pSizes[i]);
5202 }
5203 }
5204 }
5205
5206 return skip;
5207}
5208
5209bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5210 uint32_t firstCounterBuffer,
5211 uint32_t counterBufferCount,
5212 const VkBuffer *pCounterBuffers,
5213 const VkDeviceSize *pCounterBufferOffsets) const {
5214 bool skip = false;
5215
5216 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5217 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5218 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5219 "%s: The firstCounterBuffer(%" PRIu32
5220 ") index is greater than or equal to "
5221 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5222 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5223 }
5224
5225 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5226 skip |=
5227 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5228 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5229 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5230 cmd_name, firstCounterBuffer, counterBufferCount,
5231 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5232 }
5233
5234 return skip;
5235}
5236
5237bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5238 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5239 const VkBuffer *pCounterBuffers,
5240 const VkDeviceSize *pCounterBufferOffsets) const {
5241 bool skip = false;
5242
5243 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5244 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5245 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5246 "%s: The firstCounterBuffer(%" PRIu32
5247 ") index is greater than or equal to "
5248 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5249 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5250 }
5251
5252 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5253 skip |=
5254 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5255 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5256 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5257 cmd_name, firstCounterBuffer, counterBufferCount,
5258 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5259 }
5260
5261 return skip;
5262}
5263
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005264bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5265 uint32_t firstInstance, VkBuffer counterBuffer,
5266 VkDeviceSize counterBufferOffset,
5267 uint32_t counterOffset, uint32_t vertexStride) const {
5268 bool skip = false;
5269
5270 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005271 skip |= LogError(
5272 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005273 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5274 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5275 }
5276
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005277 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08005278 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005279 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu64 ") must be a multiple of 4.", counterOffset);
5280 }
5281
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005282 return skip;
5283}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005284
5285bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5286 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5287 const VkAllocationCallbacks *pAllocator,
5288 VkSamplerYcbcrConversion *pYcbcrConversion,
5289 const char *apiName) const {
5290 bool skip = false;
5291
5292 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005293 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005294 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005295 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005296 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5297 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005298 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005299 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005300 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005301
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005302#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005303 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005304 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005305#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005306 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005307#endif
5308
sfricke-samsung1a72f942020-07-25 12:09:18 -07005309 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005310
5311 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005312 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005313 const VkComponentMapping components = pCreateInfo->components;
5314 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5315 if (FormatIsXChromaSubsampled(format) == true) {
5316 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5317 skip |=
5318 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005319 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5320 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005321 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005322 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005323
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005324 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5325 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5326 skip |= LogError(
5327 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5328 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5329 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5330 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5331 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005332
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005333 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5334 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5335 skip |=
5336 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005337 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5338 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005339 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005340 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005341
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005342 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5343 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5344 skip |=
5345 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005346 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5347 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005348 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005349 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005350
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005351 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005352 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5353 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5354 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005355 skip |=
5356 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005357 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5358 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005359 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5360 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005361 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005362 }
5363
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005364 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5365 // Checks same VU multiple ways in order to give a more useful error message
5366 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5367 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5368 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5369 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5370 skip |= LogError(
5371 device, vuid,
5372 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5373 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5374 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5375 string_VkComponentSwizzle(components.b));
5376 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005377
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005378 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5379 // 4 channel format = no issue
5380 // 3 = no [a]
5381 // 2 = no [b,a]
5382 // 1 = no [g,b,a]
5383 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5384 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5385
5386 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5387 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5388 skip |= LogError(device, vuid,
5389 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5390 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5391 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5392 string_VkComponentSwizzle(components.b));
5393 } else if ((channels < 3) &&
5394 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5395 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5396 skip |= LogError(device, vuid,
5397 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5398 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5399 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5400 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5401 string_VkComponentSwizzle(components.b));
5402 } else if ((channels < 2) &&
5403 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5404 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5405 skip |= LogError(device, vuid,
5406 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5407 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5408 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5409 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5410 string_VkComponentSwizzle(components.b));
5411 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005412 }
5413 }
5414
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005415 return skip;
5416}
5417
5418bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5419 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5420 const VkAllocationCallbacks *pAllocator,
5421 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5422 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5423 "vkCreateSamplerYcbcrConversion");
5424}
5425
5426bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5427 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5428 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5429 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5430 "vkCreateSamplerYcbcrConversionKHR");
5431}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005432
5433bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5434 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5435 bool skip = false;
5436 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5437 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5438
5439 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005440 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5441 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5442 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5443 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5444 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005445 }
5446 return skip;
5447}
sourav parmara96ab1a2020-04-25 16:28:23 -07005448
5449bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005450 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005451 bool skip = false;
5452 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5453 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5454 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5455 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005456 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005457 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5458 skip |= LogError(
5459 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
5460 "vkCopyAccelerationStructureToMemoryKHR: The "
5461 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5462 }
5463 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
5464 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
5465 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
5466 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
5467 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
5468 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005469 return skip;
5470}
5471
5472bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5473 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5474 bool skip = false;
5475 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5476 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5477 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5478 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5479 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005480 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
5481 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
5482 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress must be aligned to 256 bytes.",
5483 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07005484 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005485 return skip;
5486}
5487
5488bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5489 const char *api_name) const {
5490 bool skip = false;
5491 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5492 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5493 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5494 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5495 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5496 api_name);
5497 }
5498 return skip;
5499}
5500
5501bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005502 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005503 bool skip = false;
5504 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005505 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005506 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07005507 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07005508 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
5509 "vkCopyAccelerationStructureKHR: The "
5510 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005511 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005512 return skip;
5513}
5514
5515bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5516 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5517 bool skip = false;
5518 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5519 return skip;
5520}
5521
5522bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005523 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005524 bool skip = false;
5525 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005526 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005527 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5528 }
5529 return skip;
5530}
5531
5532bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005533 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005534 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005535 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005536 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005537 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5538 skip |= LogError(
5539 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
5540 "vkCopyMemoryToAccelerationStructureKHR: The "
5541 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005542 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005543 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
5544 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07005545 return skip;
5546}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005547
sourav parmara96ab1a2020-04-25 16:28:23 -07005548bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5549 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5550 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005551 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07005552 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
5553 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
5554 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress must be aligned to 256 bytes.",
5555 pInfo->src.deviceAddress);
5556 }
sourav parmar83c31b12020-05-06 12:30:54 -07005557 return skip;
5558}
5559bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5560 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5561 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5562 bool skip = false;
5563 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5564 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5565 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5566 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5567 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5568 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5569 }
5570 return skip;
5571}
5572bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5573 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5574 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5575 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005576 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005577 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
5578 skip |= LogError(
5579 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
5580 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
5581 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5582 }
sourav parmar83c31b12020-05-06 12:30:54 -07005583 if (dataSize < accelerationStructureCount * stride) {
5584 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5585 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5586 "accelerationStructureCount (%d) *stride(%zu).",
5587 dataSize, accelerationStructureCount, stride);
5588 }
5589 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5590 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5591 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5592 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5593 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5594 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5595 }
5596 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5597 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5598 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5599 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5600 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5601 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5602 stride);
5603 }
5604 }
5605 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5606 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5607 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5608 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5609 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5610 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5611 stride);
5612 }
5613 }
sourav parmar83c31b12020-05-06 12:30:54 -07005614 return skip;
5615}
5616bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5617 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5618 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005619 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005620 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
5621 skip |= LogError(
5622 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
5623 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
5624 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07005625 }
5626 return skip;
5627}
5628
5629bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07005630 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
5631 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
5632 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
5633 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07005634 uint32_t width, uint32_t height, uint32_t depth) const {
5635 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005636 // RayGen
5637 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
5638 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
5639 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07005640 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005641 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5642 0) {
5643 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
5644 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
5645 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5646 }
5647 // Callable
5648 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5649 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
5650 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
5651 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005652 }
5653 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5654 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5655 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005656 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5657 }
5658 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5659 0) {
5660 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
5661 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
5662 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005663 }
5664 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005665 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5666 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
5667 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
5668 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005669 }
5670 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5671 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07005672 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
5673 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07005674 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005675 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5676 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
5677 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
5678 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5679 }
sourav parmar83c31b12020-05-06 12:30:54 -07005680 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005681 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5682 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
5683 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
5684 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07005685 }
5686 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5687 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5688 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005689 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5690 }
5691 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5692 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
5693 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
5694 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5695 }
5696 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
5697 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
5698 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
5699 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
5700 }
5701 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
5702 skip |=
5703 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
5704 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
5705 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07005706 }
5707
sourav parmarcd5fb182020-07-17 12:58:44 -07005708 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
5709 skip |=
5710 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
5711 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
5712 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
5713 }
5714
5715 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
5716 skip |=
5717 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
5718 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
5719 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07005720 }
5721 return skip;
5722}
5723
sourav parmarcd5fb182020-07-17 12:58:44 -07005724bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
5725 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
5726 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
5727 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07005728 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005729 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005730 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
5731 skip |= LogError(
5732 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
5733 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
5734 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005735 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005736 // RayGen
5737 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
5738 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
5739 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07005740 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005741 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5742 0) {
5743 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
5744 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
5745 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5746 }
5747 // Callabe
5748 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5749 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
5750 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
5751 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005752 }
5753 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5754 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07005755 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
5756 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5757 }
5758 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5759 0) {
5760 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
5761 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
5762 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005763 }
5764 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005765 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5766 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
5767 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
5768 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005769 }
5770 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5771 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07005772 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
5773 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07005774 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005775 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5776 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
5777 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
5778 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5779 }
sourav parmar83c31b12020-05-06 12:30:54 -07005780 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005781 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5782 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
5783 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
5784 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005785 }
5786 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5787 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07005788 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
5789 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5790 }
5791 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5792 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
5793 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
5794 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005795 }
5796
sourav parmarcd5fb182020-07-17 12:58:44 -07005797 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
5798 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
5799 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07005800 }
5801 return skip;
5802}
5803bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5804 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5805 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5806 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5807 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5808 uint32_t width, uint32_t height, uint32_t depth) const {
5809 bool skip = false;
5810 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5811 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5812 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5813 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5814 }
5815 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5816 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5817 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5818 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5819 }
5820 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5821 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5822 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5823 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5824 }
5825
5826 // hitShader
5827 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5828 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5829 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5830 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5831 }
5832 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5833 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5834 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5835 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5836 }
5837 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5838 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5839 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5840 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5841 }
5842
5843 // missShader
5844 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5845 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5846 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5847 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5848 }
5849 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5850 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5851 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5852 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5853 }
5854 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5855 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5856 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5857 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5858 }
5859
5860 // raygenShader
5861 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5862 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5863 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07005864 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5865 }
5866 if (width > device_limits.maxComputeWorkGroupCount[0]) {
5867 skip |=
5868 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
5869 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
5870 }
5871 if (height > device_limits.maxComputeWorkGroupCount[1]) {
5872 skip |=
5873 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
5874 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
5875 }
5876 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
5877 skip |=
5878 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
5879 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07005880 }
5881 return skip;
5882}
5883
sourav parmar83c31b12020-05-06 12:30:54 -07005884bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005885 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
5886 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07005887 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005888 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
5889 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005890 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
5891 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005892 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07005893 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5894 }
5895 return skip;
5896}
5897
Piers Daniell39842ee2020-07-10 16:42:33 -06005898bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
5899 const VkViewport *pViewports) const {
5900 bool skip = false;
5901
5902 if (!physical_device_features.multiViewport) {
5903 if (viewportCount != 1) {
5904 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
5905 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5906 ") is not 1.",
5907 viewportCount);
5908 }
5909 } else { // multiViewport enabled
5910 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
5911 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
5912 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
5913 ") must "
5914 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5915 viewportCount, device_limits.maxViewports);
5916 }
5917 }
5918
5919 if (pViewports) {
5920 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
5921 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
5922 const char *fn_name = "vkCmdSetViewportWithCountEXT";
5923 skip |= manual_PreCallValidateViewport(
5924 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
5925 }
5926 }
5927
5928 return skip;
5929}
5930
5931bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
5932 const VkRect2D *pScissors) const {
5933 bool skip = false;
5934
5935 if (!physical_device_features.multiViewport) {
5936 if (scissorCount != 1) {
5937 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
5938 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5939 ") must "
5940 "be 1 when the multiViewport feature is disabled.",
5941 scissorCount);
5942 }
5943 } else { // multiViewport enabled
5944 if (scissorCount == 0) {
5945 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5946 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5947 ") must "
5948 "be great than zero.",
5949 scissorCount);
5950 } else if (scissorCount > device_limits.maxViewports) {
5951 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5952 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5953 ") must "
5954 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5955 scissorCount, device_limits.maxViewports);
5956 }
5957 }
5958
5959 if (pScissors) {
5960 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
5961 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
5962
5963 if (scissor.offset.x < 0) {
5964 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5965 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
5966 scissor.offset.x);
5967 }
5968
5969 if (scissor.offset.y < 0) {
5970 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5971 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
5972 scissor.offset.y);
5973 }
5974
5975 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5976 if (x_sum > INT32_MAX) {
5977 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
5978 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5979 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5980 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
5981 }
5982
5983 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5984 if (y_sum > INT32_MAX) {
5985 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
5986 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5987 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5988 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
5989 }
5990 }
5991 }
5992
5993 return skip;
5994}
5995
5996bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5997 uint32_t bindingCount, const VkBuffer *pBuffers,
5998 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
5999 const VkDeviceSize *pStrides) const {
6000 bool skip = false;
6001 if (firstBinding >= device_limits.maxVertexInputBindings) {
6002 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
6003 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
6004 firstBinding, device_limits.maxVertexInputBindings);
6005 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6006 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
6007 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
6008 "maxVertexInputBindings (%u)",
6009 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6010 }
6011
6012 for (uint32_t i = 0; i < bindingCount; ++i) {
6013 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006014 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06006015 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
6016 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
6017 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
6018 } else {
6019 if (pOffsets[i] != 0) {
6020 skip |=
6021 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
6022 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
6023 }
6024 }
6025 }
6026 if (pStrides) {
6027 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
6028 skip |=
6029 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
6030 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%u) must be less than maxVertexInputBindingStride (%u)", i,
6031 pStrides[i], device_limits.maxVertexInputBindingStride);
6032 }
6033 }
6034 }
6035
6036 return skip;
6037}
sourav parmarcd5fb182020-07-17 12:58:44 -07006038
6039bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6040 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6041 bool skip = false;
6042 for (uint32_t i = 0; i < infoCount; ++i) {
6043 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6044 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6045 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6046 }
6047 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6048 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6049 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6050 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6051 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6052 api_name);
6053 }
6054 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6055 skip |=
6056 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6057 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6058 }
6059 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6060 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6061 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6062 }
6063 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6064 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6065 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6066 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6067 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6068 api_name);
6069 }
6070 if (pInfos[i].pGeometries) {
6071 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6072 skip |= validate_ranged_enum(
6073 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6074 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6075 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6076 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006077 skip |= validate_struct_type(
6078 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6079 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6080 &(pInfos[i].pGeometries[j].geometry.triangles),
6081 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6082 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6083 skip |= validate_struct_pnext(
6084 api_name,
6085 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6086 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6087 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6088 skip |=
6089 validate_ranged_enum(api_name,
6090 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6091 ParameterName::IndexVector{i, j}),
6092 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6093 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6094 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6095 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6096 &pInfos[i].pGeometries[j].geometry.triangles,
6097 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6098 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6099 skip |= validate_ranged_enum(
6100 api_name,
6101 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6102 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6103 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6104
6105 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6106 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6107 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6108 }
6109 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6110 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6111 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6112 skip |=
6113 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6114 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6115 api_name);
6116 }
6117 }
6118 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6119 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6120 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6121 &pInfos[i].pGeometries[j].geometry.instances,
6122 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6123 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6124 skip |= validate_struct_type(
6125 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6126 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6127 &(pInfos[i].pGeometries[j].geometry.instances),
6128 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6129 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6130 skip |= validate_struct_pnext(
6131 api_name,
6132 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6133 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6134 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6135
6136 skip |= validate_bool32(api_name,
6137 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6138 ParameterName::IndexVector{i, j}),
6139 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6140 }
6141 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6142 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6143 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6144 &pInfos[i].pGeometries[j].geometry.aabbs,
6145 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6146 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6147 skip |= validate_struct_type(
6148 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6149 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6150 &(pInfos[i].pGeometries[j].geometry.aabbs),
6151 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6152 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6153 skip |= validate_struct_pnext(
6154 api_name,
6155 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6156 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6157 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6158 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6159 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6160 "(%s):stride must be less than or equal to 2^32-1", api_name);
6161 }
6162 }
6163 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6164 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6165 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6166 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6167 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6168 api_name);
6169 }
6170 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6171 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6172 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6173 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6174 "of elements of"
6175 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6176 api_name);
6177 }
6178 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6179 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6180 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6181 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6182 api_name);
6183 }
6184 }
6185 }
6186 }
6187 if (pInfos[i].ppGeometries != NULL) {
6188 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6189 skip |= validate_ranged_enum(
6190 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6191 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6192 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6193 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006194 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6195 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6196 &pInfos[i].ppGeometries[j]->geometry.triangles,
6197 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6198 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6199 skip |= validate_struct_type(
6200 api_name,
6201 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6202 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6203 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6204 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6205 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6206 skip |= validate_struct_pnext(
6207 api_name,
6208 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6209 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6210 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6211 skip |= validate_ranged_enum(api_name,
6212 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6213 ParameterName::IndexVector{i, j}),
6214 "VkFormat", AllVkFormatEnums,
6215 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6216 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6217 skip |= validate_ranged_enum(api_name,
6218 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6219 ParameterName::IndexVector{i, j}),
6220 "VkIndexType", AllVkIndexTypeEnums,
6221 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6222 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6223 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6224 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6225 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6226 }
6227 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6228 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6229 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6230 skip |=
6231 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6232 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6233 api_name);
6234 }
6235 }
6236 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6237 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6238 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6239 &pInfos[i].ppGeometries[j]->geometry.instances,
6240 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6241 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6242 skip |= validate_struct_type(
6243 api_name,
6244 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6245 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6246 &(pInfos[i].ppGeometries[j]->geometry.instances),
6247 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6248 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6249 skip |= validate_struct_pnext(
6250 api_name,
6251 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6252 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6253 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6254 skip |= validate_bool32(api_name,
6255 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6256 ParameterName::IndexVector{i, j}),
6257 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6258 }
6259 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6260 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6261 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6262 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6263 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6264 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6265 skip |= validate_struct_type(
6266 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6267 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6268 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6269 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6270 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6271 skip |= validate_struct_pnext(
6272 api_name,
6273 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6274 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6275 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6276 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6277 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6278 "(%s):stride must be less than or equal to 2^32-1", api_name);
6279 }
6280 }
6281 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6282 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6283 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6284 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6285 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6286 api_name);
6287 }
6288 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6289 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6290 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6291 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6292 "of elements of"
6293 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6294 api_name);
6295 }
6296 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6297 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6298 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6299 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6300 api_name);
6301 }
6302 }
6303 }
6304 }
6305 }
6306 return skip;
6307}
6308bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6309 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6310 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6311 bool skip = false;
6312 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6313 for (uint32_t i = 0; i < infoCount; ++i) {
6314 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6315 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6316 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6317 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6318 "scratchData.deviceAddress member must be a multiple of "
6319 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6320 }
6321 for (uint32_t k = 0; k < infoCount; ++k) {
6322 if (i == k) continue;
6323 bool found = false;
6324 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6325 skip |= LogError(
6326 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6327 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6328 "not be "
6329 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6330 i, k);
6331 found = true;
6332 }
6333 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6334 skip |= LogError(
6335 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
6336 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
6337 "not be "
6338 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6339 i, k);
6340 found = true;
6341 }
6342 if (found) break;
6343 }
6344 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6345 if (pInfos[i].pGeometries) {
6346 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6347 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6348 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6349 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6350 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6351 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6352 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6353 }
6354 } else {
6355 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6356 skip |=
6357 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6358 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6359 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6360 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6361 }
6362 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006363 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006364 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6365 skip |= LogError(
6366 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6367 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6368 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6369 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006370 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6371 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006372 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6373 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6374 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6375 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6376 }
6377 }
6378 } else if (pInfos[i].ppGeometries) {
6379 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6380 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6381 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6382 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6383 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6384 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6385 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6386 }
6387 } else {
6388 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6389 skip |=
6390 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6391 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6392 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6393 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6394 }
6395 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006396 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006397 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6398 skip |= LogError(
6399 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6400 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6401 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6402 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006403 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6404 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006405 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6406 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6407 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6408 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6409 }
6410 }
6411 }
6412 }
6413 }
6414 return skip;
6415}
6416
6417bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
6418 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6419 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
6420 const uint32_t *const *ppMaxPrimitiveCounts) const {
6421 bool skip = false;
6422 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
6423 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006424 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006425 if (!ray_tracing_acceleration_structure_features ||
6426 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
6427 skip |= LogError(
6428 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
6429 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
6430 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
6431 }
6432 for (uint32_t i = 0; i < infoCount; ++i) {
6433 if (pInfos[i].mode == VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR) {
6434 if (pInfos[i].srcAccelerationStructure == VK_NULL_HANDLE) {
6435 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03666",
6436 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, if its mode member is "
6437 "VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, its srcAccelerationStructure member must not be "
6438 "VK_NULL_HANDLE.");
6439 }
6440 }
6441 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6442 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6443 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
6444 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
6445 "scratchData.deviceAddress member must be a multiple of "
6446 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6447 }
6448 for (uint32_t k = 0; k < infoCount; ++k) {
6449 if (i == k) continue;
6450 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6451 skip |=
6452 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
6453 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
6454 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
6455 "any other element [%d) of pInfos.",
6456 i, k);
6457 break;
6458 }
6459 }
6460 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6461 if (pInfos[i].pGeometries) {
6462 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6463 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6464 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6465 skip |= LogError(
6466 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6467 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6468 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6469 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6470 }
6471 } else {
6472 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6473 skip |= LogError(
6474 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6475 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6476 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6477 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6478 }
6479 }
6480 }
6481 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6482 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6483 skip |= LogError(
6484 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6485 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6486 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6487 }
6488 }
6489 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6490 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
6491 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6492 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6493 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6494 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6495 }
6496 }
6497 } else if (pInfos[i].ppGeometries) {
6498 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6499 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6500 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6501 skip |= LogError(
6502 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6503 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6504 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6505 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6506 }
6507 } else {
6508 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6509 skip |= LogError(
6510 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6511 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6512 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6513 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6514 }
6515 }
6516 }
6517 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6518 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6519 skip |= LogError(
6520 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6521 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6522 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6523 }
6524 }
6525 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6526 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
6527 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6528 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6529 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6530 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6531 }
6532 }
6533 }
6534 }
6535 }
6536 return skip;
6537}
6538
6539bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
6540 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
6541 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6542 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6543 bool skip = false;
6544 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
6545 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006546 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006547 if (!ray_tracing_acceleration_structure_features ||
6548 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6549 skip |=
6550 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
6551 "vkBuildAccelerationStructuresKHR: The "
6552 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
6553 }
6554 for (uint32_t i = 0; i < infoCount; ++i) {
6555 for (uint32_t j = 0; j < infoCount; ++j) {
6556 if (i == j) continue;
6557 bool found = false;
6558 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6559 skip |= LogError(
6560 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6561 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
6562 "not be "
6563 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6564 i, j);
6565 found = true;
6566 }
6567 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6568 skip |= LogError(
6569 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
6570 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
6571 "not be "
6572 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6573 i, j);
6574 found = true;
6575 }
6576 if (found) break;
6577 }
6578 }
6579 return skip;
6580}
6581
6582bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
6583 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
6584 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
6585 bool skip = false;
6586 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
6587 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006588 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
6589 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006590 if (!(ray_tracing_pipeline_features || ray_query_features) ||
6591 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
6592 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
6593 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
6594 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
6595 }
6596 return skip;
6597}
sfricke-samsungecafb192021-01-17 08:21:14 -08006598
6599bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
6600 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
6601 const VkAllocationCallbacks *pAllocator,
6602 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
6603 bool skip = false;
6604 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
6605 if (private_data_features && private_data_features->privateData == VK_FALSE) {
6606 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
6607 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
6608 }
6609 return skip;
6610}