blob: 1cbf48ff86fb51eb4fa7d37dc7697e755e1b3db3 [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) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800951 skip |= LogError(
952 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 (%u) exceeds device "
955 "maxFramebufferWidth (%u)",
956 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500957 }
958
959 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800960 skip |= LogError(
961 device, "VUID-VkImageCreateInfo-format-02537",
962 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
963 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%u) exceeds device "
964 "maxFramebufferHeight (%u)",
965 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500966 }
967 }
968
969 if (!physical_device_features.shaderStorageImageMultisample &&
970 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
971 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
972 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700973 LogError(device, "VUID-VkImageCreateInfo-format-02538",
974 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
975 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
976 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500977 }
978
979 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
980 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700981 skip |= LogError(
982 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500983 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
984 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
985 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
986 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
987 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700988 skip |= LogError(
989 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500990 "vkCreateImage(): Depth-stencil image in which usage does not include "
991 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
992 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
993 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
994 }
995
996 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
997 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700998 skip |= LogError(
999 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001000 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1001 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1002 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1003 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1004 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001005 skip |= LogError(
1006 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001007 "vkCreateImage(): Depth-stencil image in which usage does not include "
1008 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1009 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1010 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1011 }
1012 }
1013 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001014
1015 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1016 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1017 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1018 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1019 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1020 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001021
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001022 std::vector<uint64_t> image_create_drm_format_modifiers;
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001023 if (device_extensions.vk_ext_image_drm_format_modifier) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001024 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1025 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001026 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1027 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1028 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1029 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1030 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1031 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1032 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001033 } else if (drm_format_mod_list != nullptr) {
1034 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1035 } else if (drm_format_mod_list != nullptr) {
1036 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1037 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1038 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001039 }
1040 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1041 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1042 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1043 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1044 "in the pNext chain");
1045 }
1046 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001047
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001048 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001049 bool image_create_maybe_linear = false;
1050 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1051 image_create_maybe_linear = true;
1052 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1053 image_create_maybe_linear = false;
1054 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1055 image_create_maybe_linear =
1056 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001057 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001058 }
1059
1060 // If multi-sample, validate type, usage, tiling and mip levels.
1061 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
1062 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
1063 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1064 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1065 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1066 }
1067
1068 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
1069 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1070 image_create_maybe_linear)) {
1071 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1072 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1073 }
1074
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001075 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1076 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1077 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1078 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1079 "imageType must be VK_IMAGE_TYPE_2D.");
1080 }
1081 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1082 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1083 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1084 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1085 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001086 }
1087 if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
1088 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1089 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1090 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1091 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1092 }
1093 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1094 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1095 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1096 "imageType must be VK_IMAGE_TYPE_2D.");
1097 }
1098 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
1099 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1100 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1101 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1102 }
1103 if (pCreateInfo->mipLevels != 1) {
1104 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1105 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1106 pCreateInfo->mipLevels);
1107 }
1108 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001109
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001110 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001111 if (swapchain_create_info != nullptr) {
1112 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1113 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1114 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1115 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1116 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1117 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1118
1119 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1120 // also implicitly forces the check above that extent.depth is 1
1121 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1122 string_VkImageType(pCreateInfo->imageType));
1123 }
1124 if (pCreateInfo->mipLevels != 1) {
1125 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1126 pCreateInfo->mipLevels);
1127 }
1128 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1129 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1130 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1131 }
1132 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1133 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1134 base_message, string_VkImageTiling(pCreateInfo->tiling));
1135 }
1136 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1137 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1138 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1139 }
1140 const VkImageCreateFlags valid_flags =
1141 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001142 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001143 if ((pCreateInfo->flags & ~valid_flags) != 0) {
1144 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
1145 pCreateInfo->flags);
1146 }
1147 }
1148 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001149
1150 // If Chroma subsampled format ( _420_ or _422_ )
1151 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1152 skip |=
1153 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1154 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1155 ") must be a multiple of 2.",
1156 string_VkFormat(image_format), pCreateInfo->extent.width);
1157 }
1158 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1159 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1160 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1161 ") must be a multiple of 2.",
1162 string_VkFormat(image_format), pCreateInfo->extent.height);
1163 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001164 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001165
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001166 return skip;
1167}
1168
Jeff Bolz99e3f632020-03-24 22:59:22 -05001169bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1170 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1171 bool skip = false;
1172
1173 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001174 // Validate feature set if using CUBE_ARRAY
1175 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1176 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1177 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1178 "enabling the imageCubeArray feature.");
1179 }
1180
Jeff Bolz99e3f632020-03-24 22:59:22 -05001181 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1182 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1183 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001184 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001185 pCreateInfo->subresourceRange.layerCount);
1186 }
1187 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001188 skip |= LogError(
1189 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1190 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1191 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001192 }
1193 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001194
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001195 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001196 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1197 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1198 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1199 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1200 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1201 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1202 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1203 }
1204 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1205 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1206 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1207 "not an ASTC format.",
1208 string_VkFormat(pCreateInfo->format));
1209 }
1210 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001211
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001212 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001213 if (ycbcr_conversion != nullptr) {
1214 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1215 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1216 skip |= LogError(
1217 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1218 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1219 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1220 "r swizzle = %s\n"
1221 "g swizzle = %s\n"
1222 "b swizzle = %s\n"
1223 "a swizzle = %s\n",
1224 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1225 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1226 }
1227 }
1228 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001229 }
1230 return skip;
1231}
1232
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001233bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001234 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001235 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001236
1237 // Note: for numerical correctness
1238 // - float comparisons should expect NaN (comparison always false).
1239 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1240
1241 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001242 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001243 if (v1_f <= 0.0f) return true;
1244
1245 float intpart;
1246 const float fract = modff(v1_f, &intpart);
1247
1248 assert(std::numeric_limits<float>::radix == 2);
1249 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1250 if (intpart >= u32_max_plus1) return false;
1251
1252 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001253 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001254 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001255 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001256 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001257 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001258 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001259 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001260 };
1261
1262 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1263 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1264 return (v1_f <= v2_f);
1265 };
1266
1267 // width
1268 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001269 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001270
1271 if (!(viewport.width > 0.0f)) {
1272 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001273 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1274 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001275 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1276 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001277 skip |= LogError(object, "VUID-VkViewport-width-01771",
1278 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1279 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001280 }
1281
1282 // height
1283 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001284 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001285 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001286
1287 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1288 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001289 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1290 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001291 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1292 height_healthy = false;
1293
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001294 skip |= LogError(object, "VUID-VkViewport-height-01773",
1295 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1296 ").",
1297 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001298 }
1299
1300 // x
1301 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001302 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001303 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001304 skip |= LogError(object, "VUID-VkViewport-x-01774",
1305 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1306 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001307 }
1308
1309 // x + width
1310 if (x_healthy && width_healthy) {
1311 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001312 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001313 skip |= LogError(
1314 object, "VUID-VkViewport-x-01232",
1315 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1316 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1317 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001318 }
1319 }
1320
1321 // y
1322 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001323 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001324 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001325 skip |= LogError(object, "VUID-VkViewport-y-01775",
1326 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1327 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001328 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001329 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001330 skip |= LogError(object, "VUID-VkViewport-y-01776",
1331 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1332 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001333 }
1334
1335 // y + height
1336 if (y_healthy && height_healthy) {
1337 const float boundary = viewport.y + viewport.height;
1338
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001339 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001340 skip |= LogError(object, "VUID-VkViewport-y-01233",
1341 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1342 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1343 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001344 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001345 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001346 LogError(object, "VUID-VkViewport-y-01777",
1347 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1348 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1349 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001350 }
1351 }
1352
sfricke-samsungfd06d422021-01-22 02:17:21 -08001353 // 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 -07001354 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001355 // minDepth
1356 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001357 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001358 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001359 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1360 "[0.0, 1.0] range.",
1361 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001362 }
1363
1364 // maxDepth
1365 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001366 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001367 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001368 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1369 "[0.0, 1.0] range.",
1370 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001371 }
1372 }
1373
1374 return skip;
1375}
1376
Dave Houlton142c4cb2018-10-17 15:04:41 -06001377struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001378 VkShadingRatePaletteEntryNV shadingRate;
1379 uint32_t width;
1380 uint32_t height;
1381};
1382
1383// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001384static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001385 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1386 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1387 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1388 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1389 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1390 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001391};
1392
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001393bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001394 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001395
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001396 SampleOrderInfo *sample_order_info;
1397 uint32_t info_idx = 0;
1398 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1399 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1400 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001401 break;
1402 }
1403 }
1404
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001405 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001406 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1407 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1408 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001409 return skip;
1410 }
1411
Dave Houlton142c4cb2018-10-17 15:04:41 -06001412 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001413 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001414 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1415 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1416 ") must "
1417 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1418 "is set in framebufferNoAttachmentsSampleCounts.",
1419 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001420 }
1421
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001422 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001423 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1424 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1425 ") must "
1426 "be equal to the product of sampleCount (=%" PRIu32
1427 "), the fragment width for shadingRate "
1428 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001429 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001430 }
1431
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001432 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001433 skip |= LogError(
1434 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001435 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1436 ") must "
1437 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001438 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001439 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001440
1441 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001442 // the first width*height*sampleCount bits to all be set. Note: There is no
1443 // guarantee that 64 bits is enough, but practically it's unlikely for an
1444 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001445 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001446 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001447 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001448 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1449 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001450 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1451 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001452 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001453 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001454 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1455 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001456 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001457 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001458 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1459 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001460 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001461 uint32_t idx =
1462 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1463 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001464 }
1465
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001466 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1467 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001468 skip |= LogError(
1469 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001470 "The array pSampleLocations must contain exactly one entry for "
1471 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001472 }
1473
1474 return skip;
1475}
1476
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001477bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1478 uint32_t createInfoCount,
1479 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1480 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001481 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001482 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001483
1484 if (pCreateInfos != nullptr) {
1485 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001486 bool has_dynamic_viewport = false;
1487 bool has_dynamic_scissor = false;
1488 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001489 bool has_dynamic_depth_bias = false;
1490 bool has_dynamic_blend_constant = false;
1491 bool has_dynamic_depth_bounds = false;
1492 bool has_dynamic_stencil_compare = false;
1493 bool has_dynamic_stencil_write = false;
1494 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001495 bool has_dynamic_viewport_w_scaling_nv = false;
1496 bool has_dynamic_discard_rectangle_ext = false;
1497 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001498 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001499 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001500 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001501 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001502 bool has_dynamic_cull_mode = false;
1503 bool has_dynamic_front_face = false;
1504 bool has_dynamic_primitive_topology = false;
1505 bool has_dynamic_viewport_with_count = false;
1506 bool has_dynamic_scissor_with_count = false;
1507 bool has_dynamic_vertex_input_binding_stride = false;
1508 bool has_dynamic_depth_test_enable = false;
1509 bool has_dynamic_depth_write_enable = false;
1510 bool has_dynamic_depth_compare_op = false;
1511 bool has_dynamic_depth_bounds_test_enable = false;
1512 bool has_dynamic_stencil_test_enable = false;
1513 bool has_dynamic_stencil_op = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001514 if (pCreateInfos[i].pDynamicState != nullptr) {
1515 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1516 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1517 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001518 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1519 if (has_dynamic_viewport == true) {
1520 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1521 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1522 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1523 i);
1524 }
1525 has_dynamic_viewport = true;
1526 }
1527 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1528 if (has_dynamic_scissor == true) {
1529 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1530 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1531 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1532 i);
1533 }
1534 has_dynamic_scissor = true;
1535 }
1536 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1537 if (has_dynamic_line_width == true) {
1538 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1539 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1540 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1541 i);
1542 }
1543 has_dynamic_line_width = true;
1544 }
1545 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1546 if (has_dynamic_depth_bias == true) {
1547 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1548 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1549 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1550 i);
1551 }
1552 has_dynamic_depth_bias = true;
1553 }
1554 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1555 if (has_dynamic_blend_constant == true) {
1556 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1557 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1558 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1559 i);
1560 }
1561 has_dynamic_blend_constant = true;
1562 }
1563 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1564 if (has_dynamic_depth_bounds == true) {
1565 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1566 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1567 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1568 i);
1569 }
1570 has_dynamic_depth_bounds = true;
1571 }
1572 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1573 if (has_dynamic_stencil_compare == true) {
1574 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1575 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1576 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1577 i);
1578 }
1579 has_dynamic_stencil_compare = true;
1580 }
1581 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1582 if (has_dynamic_stencil_write == true) {
1583 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1584 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1585 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1586 i);
1587 }
1588 has_dynamic_stencil_write = true;
1589 }
1590 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1591 if (has_dynamic_stencil_reference == true) {
1592 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1593 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1594 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1595 i);
1596 }
1597 has_dynamic_stencil_reference = true;
1598 }
1599 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1600 if (has_dynamic_viewport_w_scaling_nv == true) {
1601 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1602 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1603 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1604 i);
1605 }
1606 has_dynamic_viewport_w_scaling_nv = true;
1607 }
1608 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1609 if (has_dynamic_discard_rectangle_ext == true) {
1610 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1611 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1612 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1613 i);
1614 }
1615 has_dynamic_discard_rectangle_ext = true;
1616 }
1617 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1618 if (has_dynamic_sample_locations_ext == true) {
1619 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1620 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1621 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1622 i);
1623 }
1624 has_dynamic_sample_locations_ext = true;
1625 }
1626 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1627 if (has_dynamic_exclusive_scissor_nv == true) {
1628 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1629 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1630 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1631 i);
1632 }
1633 has_dynamic_exclusive_scissor_nv = true;
1634 }
1635 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1636 if (has_dynamic_shading_rate_palette_nv == true) {
1637 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1638 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1639 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1640 i);
1641 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001642 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001643 }
1644 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1645 if (has_dynamic_viewport_course_sample_order_nv == true) {
1646 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1647 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1648 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1649 i);
1650 }
1651 has_dynamic_viewport_course_sample_order_nv = true;
1652 }
1653 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1654 if (has_dynamic_line_stipple == true) {
1655 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1656 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1657 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1658 i);
1659 }
1660 has_dynamic_line_stipple = true;
1661 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001662 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1663 if (has_dynamic_cull_mode) {
1664 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1665 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1666 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1667 i);
1668 }
1669 has_dynamic_cull_mode = true;
1670 }
1671 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1672 if (has_dynamic_front_face) {
1673 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1674 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1675 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1676 i);
1677 }
1678 has_dynamic_front_face = true;
1679 }
1680 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1681 if (has_dynamic_primitive_topology) {
1682 skip |= LogError(
1683 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1684 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1685 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1686 i);
1687 }
1688 has_dynamic_primitive_topology = true;
1689 }
1690 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1691 if (has_dynamic_viewport_with_count) {
1692 skip |= LogError(
1693 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1694 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1695 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1696 i);
1697 }
1698 has_dynamic_viewport_with_count = true;
1699 }
1700 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1701 if (has_dynamic_scissor_with_count) {
1702 skip |= LogError(
1703 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1704 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1705 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1706 i);
1707 }
1708 has_dynamic_scissor_with_count = true;
1709 }
1710 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1711 if (has_dynamic_vertex_input_binding_stride) {
1712 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1713 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1714 "listed twice in the "
1715 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1716 i);
1717 }
1718 has_dynamic_vertex_input_binding_stride = true;
1719 }
1720 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1721 if (has_dynamic_depth_test_enable) {
1722 skip |= LogError(
1723 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1724 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1725 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1726 i);
1727 }
1728 has_dynamic_depth_test_enable = true;
1729 }
1730 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1731 if (has_dynamic_depth_write_enable) {
1732 skip |= LogError(
1733 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1734 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1735 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1736 i);
1737 }
1738 has_dynamic_depth_write_enable = true;
1739 }
1740 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1741 if (has_dynamic_depth_compare_op) {
1742 skip |=
1743 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1744 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1745 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1746 i);
1747 }
1748 has_dynamic_depth_compare_op = true;
1749 }
1750 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1751 if (has_dynamic_depth_bounds_test_enable) {
1752 skip |= LogError(
1753 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1754 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1755 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1756 i);
1757 }
1758 has_dynamic_depth_bounds_test_enable = true;
1759 }
1760 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1761 if (has_dynamic_stencil_test_enable) {
1762 skip |= LogError(
1763 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1764 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1765 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1766 i);
1767 }
1768 has_dynamic_stencil_test_enable = true;
1769 }
1770 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1771 if (has_dynamic_stencil_op) {
1772 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1773 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1774 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1775 i);
1776 }
1777 has_dynamic_stencil_op = true;
1778 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001779 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
1780 // Not allowed for graphics pipelines
1781 skip |= LogError(
1782 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
1783 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
1784 "pCreateInfos[%d].pDynamicState->pDynamicStates[%d] but not allowed in graphic pipelines.",
1785 i, state_index);
1786 }
Petr Kraus299ba622017-11-24 03:09:03 +01001787 }
1788 }
1789
sfricke-samsung3b944422021-01-23 02:15:19 -08001790 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
1791 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
1792 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
1793 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1794 i);
1795 }
1796
1797 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
1798 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
1799 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
1800 "both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1801 i);
1802 }
1803
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001804 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04001805 if ((feedback_struct != nullptr) &&
1806 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001807 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1808 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1809 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1810 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1811 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001812 }
1813
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001814 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001815
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001816 // Collect active stages and other information
1817 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001818 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001819 bool has_eval = false;
1820 bool has_control = false;
1821 if (pCreateInfos[i].pStages != nullptr) {
1822 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1823 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1824
1825 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1826 has_control = true;
1827 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1828 has_eval = true;
1829 }
1830
1831 skip |= validate_string(
1832 "vkCreateGraphicsPipelines",
1833 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1834 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1835 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001836 }
1837
1838 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1839 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1840 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1841 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1842 pCreateInfos[i].pTessellationState,
1843 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1844 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1845
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001846 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001847 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1848
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001849 skip |= validate_struct_pnext(
1850 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1851 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
1852 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
1853 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
1854 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1855 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001856
1857 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1858 pCreateInfos[i].pTessellationState->flags,
1859 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1860 }
1861
1862 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1863 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1864 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1865 pCreateInfos[i].pInputAssemblyState,
1866 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1867 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1868
1869 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1870 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001871 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001872
1873 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1874 pCreateInfos[i].pInputAssemblyState->flags,
1875 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1876
1877 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1878 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1879 pCreateInfos[i].pInputAssemblyState->topology,
1880 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1881
1882 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1883 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1884 }
1885
1886 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001887 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001888
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001889 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001890 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1891 "vkCreateGraphicsPipelines: pararameter "
1892 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1893 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001894 }
1895
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001896 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001897 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1898 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1899 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1900 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001901 allowed_structs_vk_pipeline_vertex_input_state_create_info,
1902 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08001903 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001904 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1905 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001906 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001907 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1908 skip |=
1909 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1910 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1911 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1912 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1913 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1914
1915 skip |= validate_array(
1916 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1917 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1918 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1919 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1920
1921 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001922 for (uint32_t vertex_binding_description_index = 0;
1923 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1924 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001925 skip |= validate_ranged_enum(
1926 "vkCreateGraphicsPipelines",
1927 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1928 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001929 pCreateInfos[i]
1930 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
1931 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001932 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1933 }
1934 }
1935
1936 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001937 for (uint32_t vertex_attribute_description_index = 0;
1938 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1939 ++vertex_attribute_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001940 skip |= validate_ranged_enum(
1941 "vkCreateGraphicsPipelines",
1942 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1943 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001944 pCreateInfos[i]
1945 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
1946 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001947 "VUID-VkVertexInputAttributeDescription-format-parameter");
1948 }
1949 }
1950
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001951 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001952 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1953 "vkCreateGraphicsPipelines: pararameter "
1954 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1955 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1956 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001957 }
1958
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001959 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001960 skip |=
1961 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1962 "vkCreateGraphicsPipelines: pararameter "
1963 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1964 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1965 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001966 }
1967
1968 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001969 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1970 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001971 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1972 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001973 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1974 "vkCreateGraphicsPipelines: parameter "
1975 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1976 "(%" PRIu32 ") is not distinct.",
1977 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001978 }
1979 vertex_bindings.insert(vertex_bind_desc.binding);
1980
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001981 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001982 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1983 "vkCreateGraphicsPipelines: parameter "
1984 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1985 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1986 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001987 }
1988
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001989 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001990 skip |=
1991 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1992 "vkCreateGraphicsPipelines: parameter "
1993 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1994 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1995 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001996 }
1997 }
1998
Peter Kohautc7d9d392018-07-15 00:34:07 +02001999 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002000 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2001 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002002 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2003 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002004 skip |= LogError(
2005 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002006 "vkCreateGraphicsPipelines: parameter "
2007 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
2008 i, d, vertex_attrib_desc.location);
2009 }
2010 attribute_locations.insert(vertex_attrib_desc.location);
2011
2012 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2013 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002014 skip |= LogError(
2015 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002016 "vkCreateGraphicsPipelines: parameter "
2017 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
2018 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
2019 i, d, vertex_attrib_desc.binding, i);
2020 }
2021
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002022 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002023 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2024 "vkCreateGraphicsPipelines: parameter "
2025 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
2026 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2027 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002028 }
2029
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002030 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002031 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2032 "vkCreateGraphicsPipelines: parameter "
2033 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
2034 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2035 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002036 }
2037
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002038 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002039 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2040 "vkCreateGraphicsPipelines: parameter "
2041 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
2042 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
2043 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002044 }
2045 }
2046 }
2047
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002048 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2049 if (has_control && has_eval) {
2050 if (pCreateInfos[i].pTessellationState == nullptr) {
2051 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
2052 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
2053 "shader stage and a tessellation evaluation shader stage, "
2054 "pCreateInfos[%d].pTessellationState must not be NULL.",
2055 i, i);
2056 } else {
2057 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2058 skip |= validate_struct_pnext(
2059 "vkCreateGraphicsPipelines",
2060 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2061 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2062 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2063 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002064
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002065 skip |= validate_reserved_flags(
2066 "vkCreateGraphicsPipelines",
2067 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2068 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002069
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002070 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2071 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2072 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2073 "vkCreateGraphicsPipelines: invalid parameter "
2074 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
2075 "should be >0 and <=%u.",
2076 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2077 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002078 }
2079 }
2080 }
2081
2082 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2083 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2084 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2085 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002086 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2087 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2088 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2089 "].pViewportState (=NULL) is not a valid pointer.",
2090 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002091 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002092 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2093
2094 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002095 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2096 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2097 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2098 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002099 }
2100
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002101 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002102 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002103 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2104 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002105 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2106 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002107 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002108 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002109 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002110 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002111 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002112 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2113 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002114 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2115 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2116 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002117 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002118
2119 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002120 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002121 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002122 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002123
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002124 auto exclusive_scissor_struct =
2125 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2126 auto shading_rate_image_struct =
2127 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2128 auto coarse_sample_order_struct =
2129 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002130 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002131 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002132 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002133 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002134
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002135 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002136 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002137 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2138 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2139 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2140 ") is not 1.",
2141 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002142 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002143
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002144 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002145 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2146 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2147 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2148 ") is not 1.",
2149 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002150 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002151
Dave Houlton142c4cb2018-10-17 15:04:41 -06002152 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2153 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002154 skip |= LogError(
2155 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2156 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2157 "disabled, but pCreateInfos[%" PRIu32
2158 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2159 ") is not 1.",
2160 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002161 }
2162
Jeff Bolz9af91c52018-09-01 21:53:57 -05002163 if (shading_rate_image_struct &&
2164 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002165 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2166 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2167 "disabled, but pCreateInfos[%" PRIu32
2168 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2169 ") is neither 0 nor 1.",
2170 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002171 }
2172
Petr Krausa6103552017-11-16 21:21:58 +01002173 } else { // multiViewport enabled
2174 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002175 if (!has_dynamic_viewport_with_count) {
2176 skip |= LogError(
2177 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2178 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2179 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002180 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002181 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2182 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2183 "].pViewportState->viewportCount (=%" PRIu32
2184 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2185 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002186 } else if (has_dynamic_viewport_with_count) {
2187 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2188 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2189 "].pViewportState->viewportCount (=%" PRIu32
2190 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2191 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002192 }
Petr Krausa6103552017-11-16 21:21:58 +01002193
2194 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002195 if (!has_dynamic_scissor_with_count) {
2196 skip |= LogError(
2197 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2198 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2199 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002200 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002201 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2202 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2203 "].pViewportState->scissorCount (=%" PRIu32
2204 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2205 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002206 } else if (has_dynamic_scissor_with_count) {
2207 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2208 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2209 "].pViewportState->scissorCount (=%" PRIu32
2210 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2211 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002212 }
2213 }
2214
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002215 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002216 skip |=
2217 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2218 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2219 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2220 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002221 }
2222
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002223 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002224 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2225 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2226 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2227 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2228 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002229 }
2230
Piers Daniell39842ee2020-07-10 16:42:33 -06002231 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2232 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002233 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2234 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2235 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2236 "].pViewportState->viewportCount (=%" PRIu32 ").",
2237 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002238 }
2239
Dave Houlton142c4cb2018-10-17 15:04:41 -06002240 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002241 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002242 skip |=
2243 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2244 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2245 ") must be zero or identical to pCreateInfos[%" PRIu32
2246 "].pViewportState->viewportCount (=%" PRIu32 ").",
2247 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002248 }
2249
Dave Houlton142c4cb2018-10-17 15:04:41 -06002250 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002251 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002252 skip |= LogError(
2253 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002254 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2255 "] "
2256 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2257 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2258 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002259 }
2260
Petr Krausa6103552017-11-16 21:21:58 +01002261 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002262 skip |= LogError(
2263 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002264 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2265 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002266 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2267 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002268 }
2269
2270 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002271 skip |= LogError(
2272 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002273 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2274 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002275 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2276 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002277 }
2278
Jeff Bolz3e71f782018-08-29 23:15:45 -05002279 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002280 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2281 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2282 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002283 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002284 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2285 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2286 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2287 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002288 }
2289
Jeff Bolz9af91c52018-09-01 21:53:57 -05002290 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002291 shading_rate_image_struct->viewportCount > 0 &&
2292 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002293 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002294 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002295 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002296 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2297 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002298 i, i);
2299 }
2300
Chris Mayer328d8212018-12-11 14:16:18 +01002301 if (vp_swizzle_struct) {
2302 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002303 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2304 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2305 " does "
2306 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2307 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002308 }
2309 }
2310
Petr Krausb3fcdb42018-01-09 22:09:09 +01002311 // validate the VkViewports
2312 if (!has_dynamic_viewport && viewport_state.pViewports) {
2313 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2314 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002315 const char *fn_name = "vkCreateGraphicsPipelines";
2316 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2317 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2318 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002319 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002320 }
2321 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002322
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002323 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002324 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2325 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2326 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2327 "VK_NV_clip_space_w_scaling extension is not enabled.",
2328 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002329 }
2330
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002331 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002332 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2333 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2334 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2335 "VK_EXT_discard_rectangles extension is not enabled.",
2336 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002337 }
2338
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002339 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002340 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2341 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2342 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2343 "VK_EXT_sample_locations extension is not enabled.",
2344 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002345 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002346
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002347 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002348 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2349 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2350 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2351 "VK_NV_scissor_exclusive extension is not enabled.",
2352 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002353 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002354
2355 if (coarse_sample_order_struct &&
2356 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2357 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002358 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2359 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2360 "] "
2361 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2362 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2363 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002364 }
2365
2366 if (coarse_sample_order_struct) {
2367 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002368 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002369 }
2370 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002371
2372 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2373 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002374 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2375 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2376 "] "
2377 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2378 ") "
2379 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2380 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002381 }
2382 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002383 skip |= LogError(
2384 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002385 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2386 "] "
2387 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2388 i);
2389 }
2390 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002391 }
2392
2393 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002394 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2395 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2396 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2397 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002398 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002399 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002400 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002401 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2402 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002403 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002404 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002405 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002406 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002407 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002408 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002409 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002410 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2411 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002412
2413 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002414 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002415 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002416 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002417
2418 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002419 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002420 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2421 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2422
2423 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002424 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002425 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2426 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002427 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002428 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002429
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002430 skip |= validate_flags(
2431 "vkCreateGraphicsPipelines",
2432 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2433 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002434 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002435
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002436 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002437 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002438 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2439 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2440
2441 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002442 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002443 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2444 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2445
2446 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002447 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002448 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2449 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2450 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002451 }
John Zulauf7acac592017-11-06 11:15:53 -07002452 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002453 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002454 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2455 "vkCreateGraphicsPipelines(): parameter "
2456 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2457 i);
John Zulauf7acac592017-11-06 11:15:53 -07002458 }
2459 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2460 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2461 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002462 skip |= LogError(
2463 device,
2464
Dave Houlton413a6782018-05-22 13:01:54 -06002465 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002466 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002467 }
2468 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002469
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002470 const auto *line_state =
2471 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002472
2473 if (line_state) {
2474 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2475 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2476 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2477 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002478 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2479 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2480 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2481 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002482 }
2483 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2484 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002485 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2486 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2487 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2488 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002489 }
2490 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2491 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002492 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2493 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2494 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2495 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002496 }
2497 }
2498 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2499 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2500 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002501 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2502 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2503 "range [1,256].",
2504 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002505 }
2506 }
2507 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002508 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002509 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2510 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002511 skip |=
2512 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2513 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2514 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2515 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002516 }
2517 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2518 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002519 skip |=
2520 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2521 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2522 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2523 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002524 }
2525 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2526 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002527 skip |=
2528 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2529 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2530 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2531 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002532 }
2533 if (line_state->stippledLineEnable) {
2534 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2535 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002536 skip |=
2537 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2538 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2539 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2540 "stippledRectangularLines feature.",
2541 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002542 }
2543 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2544 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002545 skip |=
2546 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2547 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2548 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2549 "stippledBresenhamLines feature.",
2550 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002551 }
2552 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2553 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002554 skip |=
2555 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2556 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2557 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2558 "stippledSmoothLines feature.",
2559 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002560 }
2561 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2562 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002563 skip |=
2564 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2565 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2566 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2567 "stippledRectangularLines and strictLines features.",
2568 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002569 }
2570 }
2571 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002572 }
2573
Petr Krause91f7a12017-12-14 20:57:36 +01002574 bool uses_color_attachment = false;
2575 bool uses_depthstencil_attachment = false;
2576 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002577 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002578 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2579 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002580 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002581 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002582 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002583 }
2584 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002585 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002586 }
Petr Krause91f7a12017-12-14 20:57:36 +01002587 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002588 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002589 }
2590
2591 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002592 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002593 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002594 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002595 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002596 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002597
2598 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002599 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002600 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002601 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002602
2603 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002604 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002605 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2606 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2607
2608 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002609 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002610 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2611 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2612
2613 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002614 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002615 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2616 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002617 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002618
2619 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002620 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002621 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2622 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2623
2624 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002625 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002626 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2627 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2628
2629 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002630 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002631 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2632 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002633 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002634
2635 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002636 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002637 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2638 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002639 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002640
2641 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002642 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002643 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2644 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002645 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002646
2647 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002648 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002649 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2650 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002651 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002652
2653 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002654 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002655 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2656 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002657 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002658
2659 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002660 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002661 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2662 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002663 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002664
2665 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002666 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002667 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2668 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002669 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002670
2671 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002672 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002673 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2674 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002675 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002676
2677 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002678 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002679 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2680 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2681 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002682 }
2683 }
2684
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002685 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002686 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2687
Petr Krause91f7a12017-12-14 20:57:36 +01002688 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002689 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2690 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2691 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2692 pCreateInfos[i].pColorBlendState,
2693 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2694 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2695
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002696 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002697 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002698 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2699 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002700 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2701 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002702 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2703 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002704
2705 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002706 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002707 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002708 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002709
2710 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002711 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002712 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2713 pCreateInfos[i].pColorBlendState->logicOpEnable);
2714
2715 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002716 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002717 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2718 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002719 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002720 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002721
2722 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002723 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
2724 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002725 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002726 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002727 ParameterName::IndexVector{i, attachment_index}),
2728 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002729
2730 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002731 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002732 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002733 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002734 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002735 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002736 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002737
2738 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002739 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002740 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002741 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002742 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002743 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002744 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002745
2746 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002747 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002748 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002749 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002750 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002751 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002752 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002753
2754 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002755 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002756 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002757 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002758 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002759 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002760 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002761
2762 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002763 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002764 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002765 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002766 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002767 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002768 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002769
2770 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002771 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002772 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002773 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002774 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002775 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002776 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002777
2778 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002779 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002780 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002781 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002782 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002783 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002784 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002785 }
2786 }
2787
2788 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002789 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002790 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2791 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2792 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002793 }
2794
2795 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2796 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2797 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002798 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002799 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002800 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2801 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002802 }
2803 }
2804 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002805
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002806 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
2807 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01002808 if (pCreateInfos[i].basePipelineIndex != -1) {
2809 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002810 skip |=
2811 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002812 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002813 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002814 "and pCreateInfos->basePipelineIndex is not -1.",
2815 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002816 }
2817 }
2818
Petr Kraus9752aae2017-11-24 03:05:50 +01002819 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2820 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002821 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002822 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002823 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002824 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2825 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002826 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002827 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002828 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002829 skip |=
2830 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2831 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2832 "index into the pCreateInfos array, of size %d.",
2833 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002834 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002835 }
2836 }
2837
Petr Kraus9752aae2017-11-24 03:05:50 +01002838 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002839 if (!device_extensions.vk_nv_fill_rectangle) {
2840 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2841 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002842 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2843 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2844 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2845 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002846 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2847 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07002848 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002849 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002850 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2851 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2852 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002853 }
2854 } else {
2855 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2856 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2857 (physical_device_features.fillModeNonSolid == false)) {
2858 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002859 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2860 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002861 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2862 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2863 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002864 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002865 }
Petr Kraus299ba622017-11-24 03:09:03 +01002866
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002867 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002868 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002869 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2870 "The line width state is static (pCreateInfos[%" PRIu32
2871 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2872 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2873 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2874 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002875 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002876 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08002877
2878 // Validate no flags not allowed are used
2879 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2880 skip |= LogError(
2881 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2882 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags must not include VK_PIPELINE_CREATE_DISPATCH_BASE", i);
2883 }
2884 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
2885 skip |= LogError(
2886 device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
2887 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR", i);
2888 }
2889 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
2890 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
2891 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags must not include "
2892 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR",
2893 i);
2894 }
2895 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
2896 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
2897 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags must not include "
2898 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR",
2899 i);
2900 }
2901 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
2902 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
2903 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags must not include "
2904 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR",
2905 i);
2906 }
2907 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
2908 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
2909 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags must not include "
2910 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR",
2911 i);
2912 }
2913 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
2914 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
2915 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags must not include "
2916 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR",
2917 i);
2918 }
2919 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
2920 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
2921 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags must not include "
2922 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR",
2923 i);
2924 }
2925 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
2926 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
2927 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags must not include "
2928 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR",
2929 i);
2930 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002931 }
2932 }
2933
2934 return skip;
2935}
2936
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002937bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2938 uint32_t createInfoCount,
2939 const VkComputePipelineCreateInfo *pCreateInfos,
2940 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002941 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002942 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002943 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002944 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002945 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002946 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002947 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04002948 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002949 skip |=
2950 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2951 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2952 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2953 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002954 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002955
2956 // Make sure compute stage is selected
2957 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002958 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2959 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2960 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002961 }
sourav parmarcd5fb182020-07-17 12:58:44 -07002962
2963 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
2964 skip |=
2965 LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
2966 "vkCreateComputePipelines(): flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR");
2967 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002968 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002969 return skip;
2970}
2971
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002972bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002973 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002974 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002975
2976 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002977 const auto &features = physical_device_features;
2978 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002979
John Zulauf71968502017-10-26 13:51:15 -06002980 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2981 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002982 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2983 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2984 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2985 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002986 }
2987
2988 // Anistropy cannot be enabled in sampler unless enabled as a feature
2989 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002990 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2991 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2992 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002993 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002994 }
John Zulauf71968502017-10-26 13:51:15 -06002995
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002996 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2997 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002998 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2999 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3000 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3001 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003002 }
3003 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003004 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3005 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3006 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3007 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003008 }
3009 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003010 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3011 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3012 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3013 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003014 }
3015 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3016 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3017 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3018 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003019 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3020 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3021 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3022 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3023 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3024 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003025 }
3026 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003027 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3028 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3029 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003030 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003031 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003032 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3033 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3034 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003035 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003036 }
3037
3038 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3039 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003040 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3041 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003042 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003043 if (sampler_reduction != nullptr) {
3044 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3045 skip |= LogError(
3046 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3047 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3048 }
3049 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003050 }
3051
3052 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3053 // valid VkBorderColor value
3054 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3055 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3056 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003057 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3058 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003059 }
3060
3061 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
3062 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003063 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003064 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
3065 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
3066 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06003067 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003068 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
3069 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
3070 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003071 }
John Zulauf275805c2017-10-26 15:34:49 -06003072
3073 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003074 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06003075 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3076 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003077 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3078 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3079 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003080 }
3081 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003082
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003083 // Check for valid Lod range
3084 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003085 skip |=
3086 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3087 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003088 }
3089
3090 // Check mipLodBias to device limit
3091 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003092 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3093 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3094 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003095 }
3096
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003097 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003098 if (sampler_conversion != nullptr) {
3099 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3100 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3101 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3102 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003103 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003104 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003105 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3106 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3107 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3108 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3109 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3110 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3111 }
3112 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003113
3114 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3115 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3116 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3117 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3118 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3119 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3120 }
3121 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3122 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3123 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3124 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3125 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3126 }
3127 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3128 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3129 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3130 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3131 pCreateInfo->minLod, pCreateInfo->maxLod);
3132 }
3133 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3134 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3135 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3136 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3137 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3138 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3139 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3140 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3141 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3142 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3143 }
3144 if (pCreateInfo->anisotropyEnable) {
3145 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3146 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3147 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3148 }
3149 if (pCreateInfo->compareEnable) {
3150 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3151 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3152 "pCreateInfo->compareEnable must be VK_FALSE");
3153 }
3154 if (pCreateInfo->unnormalizedCoordinates) {
3155 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3156 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3157 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3158 }
3159 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003160 }
3161
Tony-LunarG7337b312020-04-15 16:40:25 -06003162 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3163 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3164 if (!device_extensions.vk_ext_custom_border_color) {
3165 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3166 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3167 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3168 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003169 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003170 if (!custom_create_info) {
3171 skip |=
3172 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3173 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3174 "struct in pNext chain.\n",
3175 string_VkBorderColor(pCreateInfo->borderColor));
3176 } else {
3177 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3178 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3179 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3180 !FormatIsSampledFloat(custom_create_info->format)))) {
3181 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3182 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3183 "whose type does not match\n",
3184 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3185 ;
3186 }
3187 }
3188 }
3189
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003190 return skip;
3191}
3192
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003193bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3194 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3195 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003196 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003197 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003198
3199 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3200 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3201 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3202 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003203 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3204 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3205 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3206 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3207 ++descriptor_index) {
3208 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003209 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003210 "vkCreateDescriptorSetLayout: required parameter "
3211 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3212 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003213 }
3214 }
3215 }
3216
3217 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3218 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3219 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003220 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3221 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3222 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3223 "values.",
3224 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003225 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003226
3227 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3228 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3229 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3230 skip |=
3231 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3232 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3233 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3234 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3235 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3236 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003237 }
3238 }
3239 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003240 return skip;
3241}
3242
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003243bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3244 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003245 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003246 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3247 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3248 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003249 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3250 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003251}
3252
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003253bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3254 const VkWriteDescriptorSet *pDescriptorWrites,
3255 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003256 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003257
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003258 if (pDescriptorWrites != NULL) {
3259 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3260 // descriptorCount must be greater than 0
3261 if (pDescriptorWrites[i].descriptorCount == 0) {
3262 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003263 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3264 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003265 }
3266
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003267 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3268 if (validateDstSet) {
3269 // dstSet must be a valid VkDescriptorSet handle
3270 skip |= validate_required_handle(vkCallingFunction,
3271 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3272 pDescriptorWrites[i].dstSet);
3273 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003274
3275 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3276 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3277 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3278 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3279 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3280 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3281 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003282 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3283 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003284 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003285 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3286 "%s(): if pDescriptorWrites[%d].descriptorType is "
3287 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3288 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3289 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3290 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003291 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3292 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003293 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3294 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003295 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3296 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003297 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003298 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3299 ParameterName::IndexVector{i, descriptor_index}),
3300 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003301 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003302 }
3303 }
3304 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3305 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3306 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3307 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3308 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3309 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3310 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003311 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003312 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003313 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3314 "%s(): if pDescriptorWrites[%d].descriptorType is "
3315 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3316 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3317 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3318 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003319 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003320 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003321 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003322 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003323 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3324 ++descriptor_index) {
3325 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3326 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3327 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003328 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3329 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003330 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003331 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3332 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003333 }
3334 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003335 }
3336 }
3337 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3338 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003339 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003340 }
3341
3342 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3343 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003344 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003345 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3346 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003347 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003348 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003349 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3350 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3351 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003352 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003353 }
3354 }
3355 }
3356 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3357 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003358 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003359 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3360 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003361 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003362 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003363 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3364 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3365 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003366 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003367 }
3368 }
3369 }
3370 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003371 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3372 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003373 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003374 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003375 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3376 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3377 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3378 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3379 "accelerationStructureCount %d member equals descriptorCount %d.",
3380 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3381 pDescriptorWrites[i].descriptorCount);
3382 }
3383 // further checks only if we have right structtype
3384 if (pnext_struct) {
3385 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3386 skip |= LogError(
3387 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3388 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3389 ".",
3390 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003391 }
sourav parmarbcee7512020-12-28 14:34:49 -08003392 if (pnext_struct->accelerationStructureCount == 0) {
3393 skip |= LogError(device,
3394 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
3395 "%s(): accelerationStructureCount must be greater than 0 .");
3396 }
3397 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003398 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003399 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3400 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3401 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3402 skip |= LogError(device,
3403 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3404 "%s(): If the nullDescriptor feature is not enabled, each member of "
3405 "pAccelerationStructures must not be VK_NULL_HANDLE.");
sourav parmarcd5fb182020-07-17 12:58:44 -07003406 }
3407 }
3408 }
sourav parmarbcee7512020-12-28 14:34:49 -08003409 }
3410 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003411 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003412 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3413 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3414 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3415 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3416 "accelerationStructureCount %d member equals descriptorCount %d.",
3417 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3418 pDescriptorWrites[i].descriptorCount);
3419 }
3420 // further checks only if we have right structtype
3421 if (pnext_struct) {
3422 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3423 skip |= LogError(
3424 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3425 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3426 ".",
3427 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003428 }
sourav parmarbcee7512020-12-28 14:34:49 -08003429 if (pnext_struct->accelerationStructureCount == 0) {
3430 skip |= LogError(device,
3431 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
3432 "%s(): accelerationStructureCount must be greater than 0 .");
3433 }
3434 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003435 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003436 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3437 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3438 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3439 skip |= LogError(device,
3440 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3441 "%s(): If the nullDescriptor feature is not enabled, each member of "
3442 "pAccelerationStructures must not be VK_NULL_HANDLE.");
sourav parmarcd5fb182020-07-17 12:58:44 -07003443 }
3444 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003445 }
3446 }
3447 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003448 }
3449 }
3450 return skip;
3451}
3452
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003453bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3454 const VkWriteDescriptorSet *pDescriptorWrites,
3455 uint32_t descriptorCopyCount,
3456 const VkCopyDescriptorSet *pDescriptorCopies) const {
3457 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3458}
3459
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003460bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003461 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003462 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003463 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3464}
3465
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003466bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3467 const VkAllocationCallbacks *pAllocator,
3468 VkRenderPass *pRenderPass) const {
3469 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3470}
3471
Mike Schuchardt2df08912020-12-15 16:28:09 -08003472bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003473 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003474 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003475 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3476}
3477
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003478bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3479 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003480 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003481 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003482
3483 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3484 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3485 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003486 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3487 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003488 return skip;
3489}
3490
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003491bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003492 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003493 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003494
3495 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3496 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003497 bool cb_is_secondary;
3498 {
3499 auto lock = cb_read_lock();
3500 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3501 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003502
Tony-LunarG3c287f62020-12-17 12:39:49 -07003503 if (cb_is_secondary) {
3504 // Implicit VUs
3505 // validate only sType here; pointer has to be validated in core_validation
3506 const bool k_not_required = false;
3507 const char *k_no_vuid = nullptr;
3508 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3509 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003510 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3511 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003512
Tony-LunarG3c287f62020-12-17 12:39:49 -07003513 if (info) {
3514 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003515 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003516 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003517 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3518 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3519 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3520 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003521
Tony-LunarG3c287f62020-12-17 12:39:49 -07003522 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003523
Tony-LunarG3c287f62020-12-17 12:39:49 -07003524 // Explicit VUs
3525 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003526 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003527 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3528 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3529 cmd_name);
3530 }
3531
3532 if (physical_device_features.inheritedQueries) {
3533 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003534 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3535 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3536 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003537 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003538 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003539 }
3540
3541 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003542 skip |=
3543 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
3544 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
3545 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
3546 } else { // !pipelineStatisticsQuery
3547 skip |=
3548 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
3549 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003550 }
3551
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003552 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003553 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003554 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003555 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3556 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
3557 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003558 commandBuffer,
3559 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07003560 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3561 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3562 }
Petr Kraus139757b2019-08-15 17:19:33 +02003563 }
3564 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003565 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003566 return skip;
3567}
3568
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003569bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003570 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003571 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003572
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003573 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003574 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003575 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3576 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3577 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003578 }
3579 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003580 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3581 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3582 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003583 }
3584 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003585 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003586 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003587 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3588 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3589 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3590 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003591 }
3592 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003593
3594 if (pViewports) {
3595 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3596 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003597 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003598 skip |= manual_PreCallValidateViewport(
3599 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003600 }
3601 }
3602
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003603 return skip;
3604}
3605
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003606bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003607 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003608 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003609
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003610 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003611 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003612 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3613 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3614 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003615 }
3616 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003617 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3618 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3619 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003620 }
3621 } else { // multiViewport enabled
3622 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003623 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003624 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3625 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3626 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3627 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003628 }
3629 }
3630
Petr Kraus6260f0a2018-02-27 21:15:55 +01003631 if (pScissors) {
3632 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3633 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003634
Petr Kraus6260f0a2018-02-27 21:15:55 +01003635 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003636 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3637 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3638 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003639 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003640
Petr Kraus6260f0a2018-02-27 21:15:55 +01003641 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003642 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3643 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3644 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003645 }
3646
3647 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3648 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003649 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3650 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3651 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3652 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003653 }
3654
3655 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3656 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003657 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3658 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3659 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3660 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003661 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003662 }
3663 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003664
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003665 return skip;
3666}
3667
Jeff Bolz5c801d12019-10-09 10:38:45 -05003668bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003669 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003670
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003671 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003672 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3673 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003674 }
3675
3676 return skip;
3677}
3678
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003679bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003680 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003681 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003682
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003683 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003684 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003685 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
3686 }
3687 if (drawCount > device_limits.maxDrawIndirectCount) {
3688 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003689 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
3690 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003691 }
3692 return skip;
3693}
3694
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003695bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003696 VkDeviceSize offset, uint32_t drawCount,
3697 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003698 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003699 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003700 skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
3701 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
3702 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003703 }
3704 if (drawCount > device_limits.maxDrawIndirectCount) {
3705 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003706 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).",
3707 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003708 }
3709 return skip;
3710}
3711
sfricke-samsungf692b972020-05-02 08:00:45 -07003712bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3713 VkDeviceSize countBufferOffset, bool khr) const {
3714 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003715 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003716 if (offset & 3) {
3717 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003718 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003719 }
3720
3721 if (countBufferOffset & 3) {
3722 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003723 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003724 countBufferOffset);
3725 }
3726 return skip;
3727}
3728
3729bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3730 VkDeviceSize offset, VkBuffer countBuffer,
3731 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3732 uint32_t stride) const {
3733 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3734}
3735
3736bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3737 VkDeviceSize offset, VkBuffer countBuffer,
3738 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3739 uint32_t stride) const {
3740 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3741}
3742
3743bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3744 VkDeviceSize countBufferOffset, bool khr) const {
3745 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003746 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003747 if (offset & 3) {
3748 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003749 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003750 }
3751
3752 if (countBufferOffset & 3) {
3753 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003754 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003755 countBufferOffset);
3756 }
3757 return skip;
3758}
3759
3760bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3761 VkDeviceSize offset, VkBuffer countBuffer,
3762 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3763 uint32_t stride) const {
3764 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3765}
3766
3767bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3768 VkDeviceSize offset, VkBuffer countBuffer,
3769 VkDeviceSize countBufferOffset,
3770 uint32_t maxDrawCount, uint32_t stride) const {
3771 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3772}
3773
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003774bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3775 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003776 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003777 bool skip = false;
3778 for (uint32_t rect = 0; rect < rectCount; rect++) {
3779 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003780 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3781 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003782 }
sfricke-samsung10867682020-04-25 02:20:39 -07003783 if (pRects[rect].rect.extent.width == 0) {
3784 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3785 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3786 }
3787 if (pRects[rect].rect.extent.height == 0) {
3788 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3789 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3790 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003791 }
3792 return skip;
3793}
3794
Andrew Fobel3abeb992020-01-20 16:33:22 -05003795bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3796 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3797 VkImageFormatProperties2 *pImageFormatProperties,
3798 const char *apiName) const {
3799 bool skip = false;
3800
3801 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003802 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003803 if (image_stencil_struct != nullptr) {
3804 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3805 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3806 // No flags other than the legal attachment bits may be set
3807 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3808 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003809 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3810 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3811 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3812 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3813 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003814 }
3815 }
3816 }
3817 }
3818
3819 return skip;
3820}
3821
3822bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3823 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3824 VkImageFormatProperties2 *pImageFormatProperties) const {
3825 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3826 "vkGetPhysicalDeviceImageFormatProperties2");
3827}
3828
3829bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3830 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3831 VkImageFormatProperties2 *pImageFormatProperties) const {
3832 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3833 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3834}
3835
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03003836bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
3837 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
3838 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
3839 bool skip = false;
3840
3841 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
3842 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
3843 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
3844 }
3845
3846 return skip;
3847}
3848
sfricke-samsung3999ef62020-02-09 17:05:59 -08003849bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3850 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3851 bool skip = false;
3852
3853 if (pRegions != nullptr) {
3854 for (uint32_t i = 0; i < regionCount; i++) {
3855 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003856 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3857 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003858 }
3859 }
3860 }
3861 return skip;
3862}
3863
Jeff Leger178b1e52020-10-05 12:22:23 -04003864bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
3865 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
3866 bool skip = false;
3867
3868 if (pCopyBufferInfo->pRegions != nullptr) {
3869 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
3870 if (pCopyBufferInfo->pRegions[i].size == 0) {
3871 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
3872 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
3873 }
3874 }
3875 }
3876 return skip;
3877}
3878
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003879bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003880 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3881 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003882 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003883
3884 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003885 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3886 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3887 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003888 }
3889
3890 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003891 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3892 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3893 "), must be greater than zero and less than or equal to 65536.",
3894 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003895 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003896 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3897 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3898 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003899 }
3900 return skip;
3901}
3902
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003903bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003904 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003905 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003906
3907 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003908 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3909 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3910 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003911 }
3912
3913 if (size != VK_WHOLE_SIZE) {
3914 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003915 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003916 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3917 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003918 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003919 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3920 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003921 }
3922 }
3923 return skip;
3924}
3925
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003926bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003927 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003928 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003929 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003930
3931 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003932 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3933 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3934 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3935 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003936 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3937 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3938 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003939 }
3940
3941 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3942 // queueFamilyIndexCount uint32_t values
3943 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003944 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3945 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3946 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3947 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003948 }
3949 }
3950
Dave Houlton413a6782018-05-22 13:01:54 -06003951 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003952 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003953 }
3954
3955 return skip;
3956}
3957
Jeff Bolz5c801d12019-10-09 10:38:45 -05003958bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003959 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003960
3961 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003962 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06003963 if (present_regions) {
3964 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003965 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003966 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3967 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07003968 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003969 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3970 "extension swapchainCount is %i. These values must be equal.",
3971 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003972 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003973 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003974 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3975 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003976 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3977 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3978 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003979 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003980 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003981 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003982 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003983 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003984 }
3985 }
3986
3987 return skip;
3988}
3989
sfricke-samsung5c1b7392020-12-13 22:17:15 -08003990bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
3991 const VkDisplayModeCreateInfoKHR *pCreateInfo,
3992 const VkAllocationCallbacks *pAllocator,
3993 VkDisplayModeKHR *pMode) const {
3994 bool skip = false;
3995
3996 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
3997 if (display_mode_parameters.visibleRegion.width == 0) {
3998 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
3999 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4000 }
4001 if (display_mode_parameters.visibleRegion.height == 0) {
4002 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4003 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4004 }
4005 if (display_mode_parameters.refreshRate == 0) {
4006 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4007 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4008 }
4009
4010 return skip;
4011}
4012
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004013#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004014bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4015 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4016 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004017 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004018 bool skip = false;
4019
4020 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004021 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4022 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004023 }
4024
4025 return skip;
4026}
4027#endif // VK_USE_PLATFORM_WIN32_KHR
4028
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004029bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004030 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004031 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004032 bool skip = false;
4033
4034 if (pCreateInfo) {
4035 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004036 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4037 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004038 }
4039
4040 if (pCreateInfo->pPoolSizes) {
4041 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4042 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004043 skip |= LogError(
4044 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004045 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004046 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004047 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4048 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004049 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4050 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4051 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4052 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4053 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004054 }
Petr Krausc8655be2017-09-27 18:56:51 +02004055 }
4056 }
4057 }
4058
4059 return skip;
4060}
4061
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004062bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004063 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004064 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004065
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004066 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004067 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004068 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4069 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4070 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004071 }
4072
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004073 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004074 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004075 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4076 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4077 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004078 }
4079
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004080 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004081 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004082 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4083 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4084 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004085 }
4086
4087 return skip;
4088}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004089
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004090bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004091 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004092 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004093
4094 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004095 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
4096 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07004097 }
4098 return skip;
4099}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004100
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004101bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4102 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004103 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004104 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004105
4106 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004107 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004108 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004109 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4110 "vkCmdDispatch(): baseGroupX (%" PRIu32
4111 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4112 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004113 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004114 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4115 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4116 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4117 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004118 }
4119
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004120 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004121 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004122 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4123 "vkCmdDispatch(): baseGroupY (%" PRIu32
4124 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4125 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004126 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004127 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4128 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4129 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4130 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004131 }
4132
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004133 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004134 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004135 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4136 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4137 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4138 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004139 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004140 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4141 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4142 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4143 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004144 }
4145
4146 return skip;
4147}
4148
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004149bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4150 VkPipelineBindPoint pipelineBindPoint,
4151 VkPipelineLayout layout, uint32_t set,
4152 uint32_t descriptorWriteCount,
4153 const VkWriteDescriptorSet *pDescriptorWrites) const {
4154 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4155}
4156
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004157bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4158 uint32_t firstExclusiveScissor,
4159 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004160 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004161 bool skip = false;
4162
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004163 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004164 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004165 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004166 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4167 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4168 ") is not 0.",
4169 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004170 }
4171 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004172 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004173 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4174 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4175 ") is not 1.",
4176 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004177 }
4178 } else { // multiViewport enabled
4179 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004180 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004181 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4182 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4183 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4184 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004185 }
4186 }
4187
Jeff Bolz3e71f782018-08-29 23:15:45 -05004188 if (pExclusiveScissors) {
4189 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4190 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4191
4192 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004193 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4194 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4195 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004196 }
4197
4198 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004199 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4200 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4201 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004202 }
4203
4204 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4205 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004206 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4207 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4208 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4209 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004210 }
4211
4212 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4213 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004214 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4215 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4216 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4217 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004218 }
4219 }
4220 }
4221
4222 return skip;
4223}
4224
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004225bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4226 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004227 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004228 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004229 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4230 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4231 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4232 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4233 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4234 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004235 }
4236
4237 return skip;
4238}
4239
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004240bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4241 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004242 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004243 bool skip = false;
4244
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004245 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004246 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004247 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004248 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4249 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4250 ") is not 0.",
4251 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004252 }
4253 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004254 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004255 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4256 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4257 ") is not 1.",
4258 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004259 }
4260 }
4261
Jeff Bolz9af91c52018-09-01 21:53:57 -05004262 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004263 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004264 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4265 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4266 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4267 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004268 }
4269
4270 return skip;
4271}
4272
Jeff Bolz5c801d12019-10-09 10:38:45 -05004273bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4274 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4275 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004276 bool skip = false;
4277
Dave Houlton142c4cb2018-10-17 15:04:41 -06004278 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004279 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4280 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4281 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004282 }
4283
4284 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004285 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004286 }
4287
4288 return skip;
4289}
4290
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004291bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004292 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004293 bool skip = false;
4294
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004295 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004296 skip |= LogError(
4297 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004298 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4299 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004300 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004301 }
4302
4303 return skip;
4304}
4305
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004306bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4307 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004308 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004309 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004310 static const int condition_multiples = 0b0011;
4311 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004312 skip |= LogError(
4313 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004314 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004315 }
Lockee1c22882019-06-10 16:02:54 -06004316 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004317 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4318 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4319 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4320 stride);
Lockee1c22882019-06-10 16:02:54 -06004321 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004322 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004323 skip |= LogError(
4324 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4325 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004326 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004327 if (drawCount > device_limits.maxDrawIndirectCount) {
4328 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004329 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4330 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004331 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004332 return skip;
4333}
4334
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004335bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4336 VkDeviceSize offset, VkBuffer countBuffer,
4337 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004338 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004339 bool skip = false;
4340
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004341 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004342 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4343 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4344 "), is not a multiple of 4.",
4345 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004346 }
4347
4348 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004349 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4350 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4351 "), is not a multiple of 4.",
4352 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004353 }
4354
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004355 return skip;
4356}
4357
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004358bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004359 const VkAllocationCallbacks *pAllocator,
4360 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004361 bool skip = false;
4362
4363 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4364 if (pCreateInfo != nullptr) {
4365 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4366 // VkQueryPipelineStatisticFlagBits values
4367 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4368 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004369 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4370 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4371 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4372 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004373 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004374 if (pCreateInfo->queryCount == 0) {
4375 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4376 "vkCreateQueryPool(): queryCount must be greater than zero.");
4377 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004378 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004379 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004380}
4381
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004382bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4383 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004384 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004385 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4386 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004387}
4388
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004389void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004390 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4391 VkResult result) {
4392 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004393 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004394}
4395
Mike Schuchardt2df08912020-12-15 16:28:09 -08004396void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004397 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4398 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004399 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004400 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004401 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004402}
4403
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004404void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4405 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004406 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004407 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004408 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004409}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004410
Tony-LunarG3c287f62020-12-17 12:39:49 -07004411void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004412 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004413 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
4414 auto lock = cb_write_lock();
4415 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004416 secondary_cb_map.insert({pCommandBuffers[cb_index], pAllocateInfo->commandPool});
Tony-LunarG3c287f62020-12-17 12:39:49 -07004417 }
4418 }
4419}
4420
4421void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004422 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004423 auto lock = cb_write_lock();
4424 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
4425 secondary_cb_map.erase(pCommandBuffers[cb_index]);
4426 }
4427}
4428
4429void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004430 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004431 auto lock = cb_write_lock();
4432 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
4433 if (item->second == commandPool) {
4434 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004435 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004436 ++item;
4437 }
4438 }
4439}
4440
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004441bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004442 const VkAllocationCallbacks *pAllocator,
4443 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004444 bool skip = false;
4445
4446 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004447 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004448 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004449 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4450 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004451 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004452
4453 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004454 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004455 if (flags_info) {
4456 flags = flags_info->flags;
4457 }
4458
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004459 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004460 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08004461 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004462 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4463 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08004464 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004465 }
4466
4467#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004468 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004469#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004470 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4471 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004472#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004473 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004474#endif
4475
4476 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004477 skip |= LogError(
4478 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004479 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4480 }
4481 if (
4482#ifdef VK_USE_PLATFORM_WIN32_KHR
4483 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4484#endif
4485 (import_memory_fd && import_memory_fd->handleType) ||
4486#ifdef VK_USE_PLATFORM_ANDROID_KHR
4487 (import_memory_ahb && import_memory_ahb->buffer) ||
4488#endif
4489 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004490 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4491 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004492 }
4493 }
4494
4495 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004496 VkBool32 capture_replay = false;
4497 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004498 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004499 if (vulkan_12_features) {
4500 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4501 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4502 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004503 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004504 if (bda_features) {
4505 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4506 buffer_device_address = bda_features->bufferDeviceAddress;
4507 }
4508 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004509 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004510 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004511 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004512 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004513 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004514 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004515 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004516 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004517 }
4518 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004519 }
4520 return skip;
4521}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004522
Jason Macnak192fa0e2019-07-26 15:07:16 -07004523bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004524 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004525 bool skip = false;
4526
4527 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4528 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4529 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004530 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004531 } else {
4532 uint32_t vertex_component_size = 0;
4533 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4534 vertex_component_size = 4;
4535 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4536 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4537 vertex_component_size = 2;
4538 }
4539 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004540 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004541 }
4542 }
4543
4544 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4545 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004546 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004547 } else {
4548 uint32_t index_element_size = 0;
4549 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4550 index_element_size = 4;
4551 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4552 index_element_size = 2;
4553 }
4554 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004555 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004556 }
4557 }
4558 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4559 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004560 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004561 }
4562 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004563 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004564 }
4565 }
4566
4567 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004568 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004569 }
4570
4571 return skip;
4572}
4573
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004574bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4575 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004576 bool skip = false;
4577
4578 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004579 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004580 }
4581 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004582 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004583 }
4584
4585 return skip;
4586}
4587
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004588bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4589 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004590 bool skip = false;
4591 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004592 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004593 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004594 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004595 }
4596 return skip;
4597}
4598
4599bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004600 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004601 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004602 bool skip = false;
4603 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004604 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4605 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4606 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004607 }
4608 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004609 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4610 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4611 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004612 }
4613 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4614 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004615 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4616 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4617 "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 -07004618 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004619 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004620 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004621 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4622 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004623 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4624 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004625 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004626 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004627 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4628 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4629 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004630 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004631 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004632 uint64_t total_triangle_count = 0;
4633 for (uint32_t i = 0; i < info.geometryCount; i++) {
4634 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004635
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004636 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004637
Jason Macnak5c954952019-07-09 15:46:12 -07004638 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4639 continue;
4640 }
4641 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4642 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004643 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004644 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4645 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4646 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004647 }
4648 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004649 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4650 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4651 for (uint32_t i = 1; i < info.geometryCount; i++) {
4652 const VkGeometryNV &geometry = info.pGeometries[i];
4653 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004654 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004655 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4656 "info.pGeometries[0].geometryType.",
4657 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004658 }
4659 }
4660 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004661 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4662 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4663 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4664 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4665 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4666 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4667 }
4668 }
4669 skip |=
4670 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004671 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004672 return skip;
4673}
4674
Ricardo Garciaa4935972019-02-21 17:43:18 +01004675bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4676 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004677 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004678 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004679 if (pCreateInfo) {
4680 if ((pCreateInfo->compactedSize != 0) &&
4681 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004682 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4683 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4684 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4685 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004686 }
Jason Macnak5c954952019-07-09 15:46:12 -07004687
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004688 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004689 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004690 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004691 return skip;
4692}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004693
Jeff Bolz5c801d12019-10-09 10:38:45 -05004694bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4695 const VkAccelerationStructureInfoNV *pInfo,
4696 VkBuffer instanceData, VkDeviceSize instanceOffset,
4697 VkBool32 update, VkAccelerationStructureNV dst,
4698 VkAccelerationStructureNV src, VkBuffer scratch,
4699 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004700 bool skip = false;
4701
4702 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004703 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004704 }
4705
4706 return skip;
4707}
4708
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004709bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4710 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4711 VkAccelerationStructureKHR *pAccelerationStructure) const {
4712 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07004713 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004714 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07004715 if (!acceleration_structure_features ||
4716 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
4717 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
4718 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
4719 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004720 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004721 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
4722 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004723 (acceleration_structure_features &&
4724 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07004725 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07004726 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
4727 "vkCreateAccelerationStructureKHR(): If createFlags includes "
4728 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
4729 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07004730 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004731 if (pCreateInfo->deviceAddress &&
4732 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
4733 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
4734 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
4735 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
4736 }
4737 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
4738 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
4739 "vkCreateAccelerationStructureKHR(): offset must be a multiple of 256 bytes", pCreateInfo->offset);
4740 }
sourav parmar83c31b12020-05-06 12:30:54 -07004741 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004742 return skip;
4743}
4744
Jason Macnak5c954952019-07-09 15:46:12 -07004745bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4746 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004747 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004748 bool skip = false;
4749 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004750 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4751 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004752 }
4753 return skip;
4754}
4755
sourav parmarcd5fb182020-07-17 12:58:44 -07004756bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
4757 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
4758 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
4759 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07004760 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004761 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-03432",
4762 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07004763 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07004764 }
4765 return skip;
4766}
4767
Peter Chen85366392019-05-14 15:20:11 -04004768bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4769 uint32_t createInfoCount,
4770 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4771 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004772 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004773 bool skip = false;
4774
4775 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004776 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04004777 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004778 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004779 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4780 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4781 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4782 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004783 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004784
4785 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004786 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07004787 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4788 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4789 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4790 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4791 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4792 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4793 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4794 }
4795 }
4796
sourav parmarf4a78252020-04-10 13:04:21 -07004797 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4798 skip |=
4799 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4800 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4801 }
4802 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4803 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4804 skip |=
4805 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4806 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4807 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4808 }
4809 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4810 if (pCreateInfos[i].basePipelineIndex != -1) {
4811 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4812 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4813 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4814 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4815 "and pCreateInfos->basePipelineIndex is not -1.");
4816 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004817 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004818 skip |=
4819 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
4820 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
4821 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
4822 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
4823 "that element.");
4824 }
sourav parmarf4a78252020-04-10 13:04:21 -07004825 }
4826 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004827 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004828 skip |=
4829 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4830 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4831 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4832 "commands pCreateInfos parameter.");
4833 }
4834 } else {
4835 if (pCreateInfos[i].basePipelineIndex != -1) {
4836 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4837 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4838 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4839 }
4840 }
4841 }
4842 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4843 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4844 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4845 }
4846 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4847 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4848 "vkCreateRayTracingPipelinesNV: flags must not include "
4849 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4850 }
4851 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4852 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4853 "vkCreateRayTracingPipelinesNV: flags must not include "
4854 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4855 }
4856 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4857 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4858 "vkCreateRayTracingPipelinesNV: flags must not include "
4859 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4860 }
4861 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4862 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4863 "vkCreateRayTracingPipelinesNV: flags must not include "
4864 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4865 }
4866 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4867 skip |= LogError(
4868 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4869 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4870 }
4871 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4872 skip |= LogError(
4873 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4874 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4875 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004876 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
4877 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
4878 "vkCreateRayTracingPipelinesNV: flags must not include "
4879 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
4880 }
4881 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
4882 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
4883 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
4884 }
Peter Chen85366392019-05-14 15:20:11 -04004885 }
4886
4887 return skip;
4888}
4889
sourav parmarcd5fb182020-07-17 12:58:44 -07004890bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
4891 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
4892 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004893 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004894 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07004895 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
4896 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
4897 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07004898 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004899 for (uint32_t i = 0; i < createInfoCount; i++) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004900 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
4901 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4902 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
4903 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
4904 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4905 }
4906 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4907 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
4908 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
4909 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
4910 }
4911 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004912 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004913 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4914 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07004915 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
4916 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
4917 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004918 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4919 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4920 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004921 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004922 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07004923 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4924 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4925 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4926 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07004927 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07004928 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4929 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4930 }
4931 }
sourav parmarf4a78252020-04-10 13:04:21 -07004932 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004933 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4934 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07004935 }
4936 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004937 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07004938 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07004939 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
4940 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004941 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004942 }
4943 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
4944 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
4945 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07004946 }
4947 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4948 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4949 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4950 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4951 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4952 skip |= LogError(
4953 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07004954 "vkCreateRayTracingPipelinesKHR: If flags includes "
4955 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07004956 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4957 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4958 "must not be VK_SHADER_UNUSED_KHR");
4959 }
4960 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4961 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4962 skip |= LogError(
4963 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07004964 "vkCreateRayTracingPipelinesKHR: If flags includes "
4965 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07004966 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4967 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4968 "element must not be VK_SHADER_UNUSED_KHR");
4969 }
4970 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004971 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
4972 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
4973 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
4974 skip |= LogError(
4975 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
4976 "vkCreateRayTracingPipelinesKHR: If "
4977 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
4978 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
4979 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
4980 }
4981 }
sourav parmarf4a78252020-04-10 13:04:21 -07004982 }
4983 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4984 if (pCreateInfos[i].basePipelineIndex != -1) {
4985 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4986 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07004987 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07004988 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4989 "and pCreateInfos->basePipelineIndex is not -1.");
4990 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004991 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004992 skip |=
4993 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
4994 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
4995 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
4996 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
4997 "element.");
4998 }
sourav parmarf4a78252020-04-10 13:04:21 -07004999 }
5000 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005001 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005002 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005003 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005004 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
5005 "commands pCreateInfos parameter %d.",
5006 pCreateInfos[i].basePipelineIndex, createInfoCount);
5007 }
5008 } else {
5009 if (pCreateInfos[i].basePipelineIndex != -1) {
5010 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07005011 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005012 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5013 }
5014 }
5015 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005016 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
5017 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
5018 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
5019 "vkCreateRayTracingPipelinesKHR: If flags includes "
5020 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
5021 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005022 }
5023 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
5024 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
5025 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
5026 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
5027 "pLibraryInfo and pLibraryInterface must be NULL.");
5028 }
5029 if (pCreateInfos[i].pLibraryInfo) {
5030 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
5031 if (pCreateInfos[i].stageCount == 0) {
5032 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
5033 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5034 "stageCount must not be 0.");
5035 }
5036 if (pCreateInfos[i].groupCount == 0) {
5037 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
5038 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5039 "groupCount must not be 0.");
5040 }
5041 } else {
5042 if (pCreateInfos[i].pLibraryInterface == NULL) {
5043 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
5044 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
5045 "is greater than 0, its "
5046 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005047 }
5048 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005049 }
5050 if (pCreateInfos[i].pLibraryInterface) {
5051 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
5052 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
5053 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
5054 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
5055 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
5056 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005057 }
5058 if (deferredOperation != VK_NULL_HANDLE) {
5059 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
5060 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
5061 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
5062 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07005063 }
5064 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005065 }
5066
5067 return skip;
5068}
5069
Mike Schuchardt21638df2019-03-16 10:52:02 -07005070#ifdef VK_USE_PLATFORM_WIN32_KHR
5071bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
5072 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005073 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07005074 bool skip = false;
5075 if (!device_extensions.vk_khr_swapchain)
5076 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
5077 if (!device_extensions.vk_khr_get_surface_capabilities_2)
5078 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
5079 if (!device_extensions.vk_khr_surface)
5080 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
5081 if (!device_extensions.vk_khr_get_physical_device_properties_2)
5082 skip |=
5083 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
5084 if (!device_extensions.vk_ext_full_screen_exclusive)
5085 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
5086 skip |= validate_struct_type(
5087 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
5088 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
5089 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
5090 if (pSurfaceInfo != NULL) {
5091 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
5092 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
5093 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
5094
5095 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
5096 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
5097 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5098 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005099 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5100 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005101
5102 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5103 }
5104 return skip;
5105}
5106#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005107
5108bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5109 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005110 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005111 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5112 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005113 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005114 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5115 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5116 }
5117 return skip;
5118}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005119
5120bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005121 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005122 bool skip = false;
5123
5124 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005125 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
5126 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005127 }
5128
5129 return skip;
5130}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005131
5132bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005133 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005134 bool skip = false;
5135
5136 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005137 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5138 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005139 }
5140
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005141 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005142 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005143 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5144 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005145 }
5146
5147 return skip;
5148}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005149
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005150bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5151 uint32_t bindingCount, const VkBuffer *pBuffers,
5152 const VkDeviceSize *pOffsets) const {
5153 bool skip = false;
5154 if (firstBinding > device_limits.maxVertexInputBindings) {
5155 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5156 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
5157 device_limits.maxVertexInputBindings);
5158 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5159 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
5160 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5161 "maxVertexInputBindings (%u)",
5162 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5163 }
5164
Jeff Bolz165818a2020-05-08 11:19:03 -05005165 for (uint32_t i = 0; i < bindingCount; ++i) {
5166 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005167 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005168 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5169 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5170 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5171 } else {
5172 if (pOffsets[i] != 0) {
5173 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5174 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5175 }
5176 }
5177 }
5178 }
5179
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005180 return skip;
5181}
5182
Mark Lobodzinski84988402019-09-11 15:27:30 -06005183bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005184 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005185 bool skip = false;
5186 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005187 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5188 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005189 }
5190 return skip;
5191}
5192
5193bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005194 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005195 bool skip = false;
5196 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005197 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5198 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005199 }
5200 return skip;
5201}
Petr Kraus3d720392019-11-13 02:52:39 +01005202
5203bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5204 VkSemaphore semaphore, VkFence fence,
5205 uint32_t *pImageIndex) const {
5206 bool skip = false;
5207
5208 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005209 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5210 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005211 }
5212
5213 return skip;
5214}
5215
5216bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5217 uint32_t *pImageIndex) const {
5218 bool skip = false;
5219
5220 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005221 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5222 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005223 }
5224
5225 return skip;
5226}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005227
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005228bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5229 uint32_t firstBinding, uint32_t bindingCount,
5230 const VkBuffer *pBuffers,
5231 const VkDeviceSize *pOffsets,
5232 const VkDeviceSize *pSizes) const {
5233 bool skip = false;
5234
5235 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5236 for (uint32_t i = 0; i < bindingCount; ++i) {
5237 if (pOffsets[i] & 3) {
5238 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5239 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5240 }
5241 }
5242
5243 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5244 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5245 "%s: The firstBinding(%" PRIu32
5246 ") index is greater than or equal to "
5247 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5248 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5249 }
5250
5251 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5252 skip |=
5253 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5254 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5255 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5256 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5257 }
5258
5259 for (uint32_t i = 0; i < bindingCount; ++i) {
5260 // pSizes is optional and may be nullptr.
5261 if (pSizes != nullptr) {
5262 if (pSizes[i] != VK_WHOLE_SIZE &&
5263 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5264 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5265 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5266 ") is not VK_WHOLE_SIZE and is greater than "
5267 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5268 cmd_name, i, pSizes[i]);
5269 }
5270 }
5271 }
5272
5273 return skip;
5274}
5275
5276bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5277 uint32_t firstCounterBuffer,
5278 uint32_t counterBufferCount,
5279 const VkBuffer *pCounterBuffers,
5280 const VkDeviceSize *pCounterBufferOffsets) const {
5281 bool skip = false;
5282
5283 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5284 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5285 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5286 "%s: The firstCounterBuffer(%" PRIu32
5287 ") index is greater than or equal to "
5288 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5289 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5290 }
5291
5292 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5293 skip |=
5294 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5295 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5296 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5297 cmd_name, firstCounterBuffer, counterBufferCount,
5298 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5299 }
5300
5301 return skip;
5302}
5303
5304bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5305 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5306 const VkBuffer *pCounterBuffers,
5307 const VkDeviceSize *pCounterBufferOffsets) const {
5308 bool skip = false;
5309
5310 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5311 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5312 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5313 "%s: The firstCounterBuffer(%" PRIu32
5314 ") index is greater than or equal to "
5315 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5316 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5317 }
5318
5319 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5320 skip |=
5321 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5322 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5323 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5324 cmd_name, firstCounterBuffer, counterBufferCount,
5325 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5326 }
5327
5328 return skip;
5329}
5330
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005331bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5332 uint32_t firstInstance, VkBuffer counterBuffer,
5333 VkDeviceSize counterBufferOffset,
5334 uint32_t counterOffset, uint32_t vertexStride) const {
5335 bool skip = false;
5336
5337 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005338 skip |= LogError(
5339 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005340 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5341 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5342 }
5343
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005344 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08005345 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005346 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu64 ") must be a multiple of 4.", counterOffset);
5347 }
5348
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005349 return skip;
5350}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005351
5352bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5353 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5354 const VkAllocationCallbacks *pAllocator,
5355 VkSamplerYcbcrConversion *pYcbcrConversion,
5356 const char *apiName) const {
5357 bool skip = false;
5358
5359 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005360 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005361 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005362 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005363 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5364 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005365 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005366 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005367 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005368
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005369#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005370 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005371 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005372#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005373 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005374#endif
5375
sfricke-samsung1a72f942020-07-25 12:09:18 -07005376 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005377
5378 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005379 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005380 const VkComponentMapping components = pCreateInfo->components;
5381 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5382 if (FormatIsXChromaSubsampled(format) == true) {
5383 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5384 skip |=
5385 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005386 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5387 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005388 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005389 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005390
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005391 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5392 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5393 skip |= LogError(
5394 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5395 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5396 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5397 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5398 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005399
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005400 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5401 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5402 skip |=
5403 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005404 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5405 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005406 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005407 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005408
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005409 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5410 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5411 skip |=
5412 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005413 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5414 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005415 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005416 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005417
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005418 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005419 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5420 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5421 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005422 skip |=
5423 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005424 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5425 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005426 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5427 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005428 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005429 }
5430
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005431 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5432 // Checks same VU multiple ways in order to give a more useful error message
5433 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5434 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5435 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5436 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5437 skip |= LogError(
5438 device, vuid,
5439 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5440 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5441 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5442 string_VkComponentSwizzle(components.b));
5443 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005444
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005445 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5446 // 4 channel format = no issue
5447 // 3 = no [a]
5448 // 2 = no [b,a]
5449 // 1 = no [g,b,a]
5450 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5451 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5452
5453 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5454 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5455 skip |= LogError(device, vuid,
5456 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5457 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5458 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5459 string_VkComponentSwizzle(components.b));
5460 } else if ((channels < 3) &&
5461 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5462 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5463 skip |= LogError(device, vuid,
5464 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5465 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5466 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5467 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5468 string_VkComponentSwizzle(components.b));
5469 } else if ((channels < 2) &&
5470 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5471 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5472 skip |= LogError(device, vuid,
5473 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5474 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5475 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5476 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5477 string_VkComponentSwizzle(components.b));
5478 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005479 }
5480 }
5481
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005482 return skip;
5483}
5484
5485bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5486 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5487 const VkAllocationCallbacks *pAllocator,
5488 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5489 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5490 "vkCreateSamplerYcbcrConversion");
5491}
5492
5493bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5494 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5495 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5496 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5497 "vkCreateSamplerYcbcrConversionKHR");
5498}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005499
5500bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5501 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5502 bool skip = false;
5503 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5504 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5505
5506 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005507 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5508 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5509 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5510 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5511 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005512 }
5513 return skip;
5514}
sourav parmara96ab1a2020-04-25 16:28:23 -07005515
5516bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005517 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005518 bool skip = false;
5519 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5520 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5521 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5522 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005523 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005524 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5525 skip |= LogError(
5526 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
5527 "vkCopyAccelerationStructureToMemoryKHR: The "
5528 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5529 }
5530 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
5531 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
5532 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
5533 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
5534 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
5535 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005536 return skip;
5537}
5538
5539bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5540 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5541 bool skip = false;
5542 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5543 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5544 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5545 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5546 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005547 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
5548 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
5549 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress must be aligned to 256 bytes.",
5550 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07005551 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005552 return skip;
5553}
5554
5555bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5556 const char *api_name) const {
5557 bool skip = false;
5558 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5559 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5560 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5561 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5562 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5563 api_name);
5564 }
5565 return skip;
5566}
5567
5568bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005569 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005570 bool skip = false;
5571 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005572 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005573 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07005574 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07005575 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
5576 "vkCopyAccelerationStructureKHR: The "
5577 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005578 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005579 return skip;
5580}
5581
5582bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5583 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5584 bool skip = false;
5585 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5586 return skip;
5587}
5588
5589bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005590 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005591 bool skip = false;
5592 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005593 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005594 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5595 }
5596 return skip;
5597}
5598
5599bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005600 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005601 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005602 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005603 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005604 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5605 skip |= LogError(
5606 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
5607 "vkCopyMemoryToAccelerationStructureKHR: The "
5608 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005609 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005610 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
5611 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07005612 return skip;
5613}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005614
sourav parmara96ab1a2020-04-25 16:28:23 -07005615bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5616 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5617 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005618 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07005619 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
5620 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
5621 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress must be aligned to 256 bytes.",
5622 pInfo->src.deviceAddress);
5623 }
sourav parmar83c31b12020-05-06 12:30:54 -07005624 return skip;
5625}
5626bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5627 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5628 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5629 bool skip = false;
5630 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5631 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5632 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5633 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5634 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5635 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5636 }
5637 return skip;
5638}
5639bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5640 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5641 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5642 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005643 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005644 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
5645 skip |= LogError(
5646 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
5647 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
5648 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5649 }
sourav parmar83c31b12020-05-06 12:30:54 -07005650 if (dataSize < accelerationStructureCount * stride) {
5651 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5652 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5653 "accelerationStructureCount (%d) *stride(%zu).",
5654 dataSize, accelerationStructureCount, stride);
5655 }
5656 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5657 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5658 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5659 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5660 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5661 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5662 }
5663 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5664 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5665 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5666 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5667 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5668 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5669 stride);
5670 }
5671 }
5672 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5673 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5674 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5675 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5676 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5677 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5678 stride);
5679 }
5680 }
sourav parmar83c31b12020-05-06 12:30:54 -07005681 return skip;
5682}
5683bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5684 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5685 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005686 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005687 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
5688 skip |= LogError(
5689 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
5690 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
5691 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07005692 }
5693 return skip;
5694}
5695
5696bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07005697 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
5698 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
5699 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
5700 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07005701 uint32_t width, uint32_t height, uint32_t depth) const {
5702 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005703 // RayGen
5704 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
5705 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
5706 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07005707 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005708 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5709 0) {
5710 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
5711 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
5712 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5713 }
5714 // Callable
5715 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5716 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
5717 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
5718 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005719 }
5720 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5721 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5722 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005723 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5724 }
5725 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5726 0) {
5727 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
5728 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
5729 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005730 }
5731 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005732 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5733 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
5734 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
5735 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005736 }
5737 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5738 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07005739 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
5740 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07005741 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005742 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5743 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
5744 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
5745 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5746 }
sourav parmar83c31b12020-05-06 12:30:54 -07005747 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005748 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5749 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
5750 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
5751 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07005752 }
5753 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5754 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5755 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005756 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5757 }
5758 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5759 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
5760 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
5761 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5762 }
5763 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
5764 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
5765 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
5766 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
5767 }
5768 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
5769 skip |=
5770 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
5771 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
5772 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07005773 }
5774
sourav parmarcd5fb182020-07-17 12:58:44 -07005775 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
5776 skip |=
5777 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
5778 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
5779 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
5780 }
5781
5782 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
5783 skip |=
5784 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
5785 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
5786 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07005787 }
5788 return skip;
5789}
5790
sourav parmarcd5fb182020-07-17 12:58:44 -07005791bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
5792 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
5793 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
5794 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07005795 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005796 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005797 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
5798 skip |= LogError(
5799 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
5800 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
5801 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005802 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005803 // RayGen
5804 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
5805 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
5806 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07005807 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005808 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5809 0) {
5810 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
5811 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
5812 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5813 }
5814 // Callabe
5815 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5816 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
5817 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
5818 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005819 }
5820 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5821 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07005822 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
5823 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5824 }
5825 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5826 0) {
5827 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
5828 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
5829 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005830 }
5831 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005832 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5833 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
5834 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
5835 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005836 }
5837 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5838 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07005839 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
5840 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07005841 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005842 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5843 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
5844 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
5845 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5846 }
sourav parmar83c31b12020-05-06 12:30:54 -07005847 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005848 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5849 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
5850 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
5851 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005852 }
5853 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5854 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07005855 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
5856 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5857 }
5858 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5859 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
5860 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
5861 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005862 }
5863
sourav parmarcd5fb182020-07-17 12:58:44 -07005864 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
5865 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
5866 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07005867 }
5868 return skip;
5869}
5870bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5871 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5872 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5873 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5874 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5875 uint32_t width, uint32_t height, uint32_t depth) const {
5876 bool skip = false;
5877 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5878 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5879 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5880 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5881 }
5882 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5883 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5884 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5885 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5886 }
5887 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5888 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5889 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5890 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5891 }
5892
5893 // hitShader
5894 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5895 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5896 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5897 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5898 }
5899 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5900 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5901 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5902 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5903 }
5904 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5905 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5906 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5907 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5908 }
5909
5910 // missShader
5911 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5912 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5913 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5914 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5915 }
5916 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5917 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5918 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5919 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5920 }
5921 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5922 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5923 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5924 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5925 }
5926
5927 // raygenShader
5928 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5929 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5930 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07005931 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5932 }
5933 if (width > device_limits.maxComputeWorkGroupCount[0]) {
5934 skip |=
5935 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
5936 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
5937 }
5938 if (height > device_limits.maxComputeWorkGroupCount[1]) {
5939 skip |=
5940 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
5941 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
5942 }
5943 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
5944 skip |=
5945 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
5946 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07005947 }
5948 return skip;
5949}
5950
sourav parmar83c31b12020-05-06 12:30:54 -07005951bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005952 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
5953 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07005954 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005955 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
5956 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005957 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
5958 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005959 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07005960 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5961 }
5962 return skip;
5963}
5964
Piers Daniell39842ee2020-07-10 16:42:33 -06005965bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
5966 const VkViewport *pViewports) const {
5967 bool skip = false;
5968
5969 if (!physical_device_features.multiViewport) {
5970 if (viewportCount != 1) {
5971 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
5972 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5973 ") is not 1.",
5974 viewportCount);
5975 }
5976 } else { // multiViewport enabled
5977 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
5978 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
5979 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
5980 ") must "
5981 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5982 viewportCount, device_limits.maxViewports);
5983 }
5984 }
5985
5986 if (pViewports) {
5987 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
5988 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
5989 const char *fn_name = "vkCmdSetViewportWithCountEXT";
5990 skip |= manual_PreCallValidateViewport(
5991 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
5992 }
5993 }
5994
5995 return skip;
5996}
5997
5998bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
5999 const VkRect2D *pScissors) const {
6000 bool skip = false;
6001
6002 if (!physical_device_features.multiViewport) {
6003 if (scissorCount != 1) {
6004 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
6005 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6006 ") must "
6007 "be 1 when the multiViewport feature is disabled.",
6008 scissorCount);
6009 }
6010 } else { // multiViewport enabled
6011 if (scissorCount == 0) {
6012 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6013 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6014 ") must "
6015 "be great than zero.",
6016 scissorCount);
6017 } else if (scissorCount > device_limits.maxViewports) {
6018 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6019 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6020 ") must "
6021 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6022 scissorCount, device_limits.maxViewports);
6023 }
6024 }
6025
6026 if (pScissors) {
6027 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
6028 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
6029
6030 if (scissor.offset.x < 0) {
6031 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6032 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
6033 scissor.offset.x);
6034 }
6035
6036 if (scissor.offset.y < 0) {
6037 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6038 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
6039 scissor.offset.y);
6040 }
6041
6042 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
6043 if (x_sum > INT32_MAX) {
6044 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
6045 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6046 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6047 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
6048 }
6049
6050 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
6051 if (y_sum > INT32_MAX) {
6052 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
6053 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6054 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6055 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
6056 }
6057 }
6058 }
6059
6060 return skip;
6061}
6062
6063bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6064 uint32_t bindingCount, const VkBuffer *pBuffers,
6065 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
6066 const VkDeviceSize *pStrides) const {
6067 bool skip = false;
6068 if (firstBinding >= device_limits.maxVertexInputBindings) {
6069 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
6070 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
6071 firstBinding, device_limits.maxVertexInputBindings);
6072 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6073 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
6074 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
6075 "maxVertexInputBindings (%u)",
6076 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6077 }
6078
6079 for (uint32_t i = 0; i < bindingCount; ++i) {
6080 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006081 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06006082 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
6083 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
6084 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
6085 } else {
6086 if (pOffsets[i] != 0) {
6087 skip |=
6088 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
6089 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
6090 }
6091 }
6092 }
6093 if (pStrides) {
6094 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
6095 skip |=
6096 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
6097 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%u) must be less than maxVertexInputBindingStride (%u)", i,
6098 pStrides[i], device_limits.maxVertexInputBindingStride);
6099 }
6100 }
6101 }
6102
6103 return skip;
6104}
sourav parmarcd5fb182020-07-17 12:58:44 -07006105
6106bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6107 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6108 bool skip = false;
6109 for (uint32_t i = 0; i < infoCount; ++i) {
6110 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6111 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6112 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6113 }
6114 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6115 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6116 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6117 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6118 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6119 api_name);
6120 }
6121 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6122 skip |=
6123 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6124 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6125 }
6126 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6127 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6128 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6129 }
6130 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6131 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6132 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6133 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6134 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6135 api_name);
6136 }
6137 if (pInfos[i].pGeometries) {
6138 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6139 skip |= validate_ranged_enum(
6140 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6141 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6142 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6143 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006144 skip |= validate_struct_type(
6145 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6146 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6147 &(pInfos[i].pGeometries[j].geometry.triangles),
6148 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6149 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6150 skip |= validate_struct_pnext(
6151 api_name,
6152 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6153 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6154 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6155 skip |=
6156 validate_ranged_enum(api_name,
6157 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6158 ParameterName::IndexVector{i, j}),
6159 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6160 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6161 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6162 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6163 &pInfos[i].pGeometries[j].geometry.triangles,
6164 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6165 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6166 skip |= validate_ranged_enum(
6167 api_name,
6168 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6169 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6170 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6171
6172 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6173 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6174 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6175 }
6176 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6177 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6178 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6179 skip |=
6180 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6181 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6182 api_name);
6183 }
6184 }
6185 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6186 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6187 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6188 &pInfos[i].pGeometries[j].geometry.instances,
6189 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6190 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6191 skip |= validate_struct_type(
6192 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6193 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6194 &(pInfos[i].pGeometries[j].geometry.instances),
6195 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6196 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6197 skip |= validate_struct_pnext(
6198 api_name,
6199 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6200 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6201 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6202
6203 skip |= validate_bool32(api_name,
6204 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6205 ParameterName::IndexVector{i, j}),
6206 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6207 }
6208 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6209 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6210 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6211 &pInfos[i].pGeometries[j].geometry.aabbs,
6212 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6213 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6214 skip |= validate_struct_type(
6215 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6216 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6217 &(pInfos[i].pGeometries[j].geometry.aabbs),
6218 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6219 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6220 skip |= validate_struct_pnext(
6221 api_name,
6222 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6223 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6224 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6225 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6226 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6227 "(%s):stride must be less than or equal to 2^32-1", api_name);
6228 }
6229 }
6230 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6231 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6232 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6233 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6234 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6235 api_name);
6236 }
6237 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6238 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6239 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6240 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6241 "of elements of"
6242 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6243 api_name);
6244 }
6245 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6246 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6247 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6248 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6249 api_name);
6250 }
6251 }
6252 }
6253 }
6254 if (pInfos[i].ppGeometries != NULL) {
6255 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6256 skip |= validate_ranged_enum(
6257 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6258 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6259 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6260 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006261 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6262 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6263 &pInfos[i].ppGeometries[j]->geometry.triangles,
6264 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6265 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6266 skip |= validate_struct_type(
6267 api_name,
6268 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6269 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6270 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6271 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6272 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6273 skip |= validate_struct_pnext(
6274 api_name,
6275 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6276 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6277 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6278 skip |= validate_ranged_enum(api_name,
6279 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6280 ParameterName::IndexVector{i, j}),
6281 "VkFormat", AllVkFormatEnums,
6282 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6283 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6284 skip |= validate_ranged_enum(api_name,
6285 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6286 ParameterName::IndexVector{i, j}),
6287 "VkIndexType", AllVkIndexTypeEnums,
6288 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6289 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6290 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6291 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6292 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6293 }
6294 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6295 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6296 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6297 skip |=
6298 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6299 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6300 api_name);
6301 }
6302 }
6303 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6304 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6305 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6306 &pInfos[i].ppGeometries[j]->geometry.instances,
6307 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6308 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6309 skip |= validate_struct_type(
6310 api_name,
6311 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6312 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6313 &(pInfos[i].ppGeometries[j]->geometry.instances),
6314 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6315 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6316 skip |= validate_struct_pnext(
6317 api_name,
6318 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6319 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6320 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6321 skip |= validate_bool32(api_name,
6322 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6323 ParameterName::IndexVector{i, j}),
6324 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6325 }
6326 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6327 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6328 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6329 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6330 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6331 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6332 skip |= validate_struct_type(
6333 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6334 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6335 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6336 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6337 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6338 skip |= validate_struct_pnext(
6339 api_name,
6340 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6341 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6342 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6343 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6344 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6345 "(%s):stride must be less than or equal to 2^32-1", api_name);
6346 }
6347 }
6348 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6349 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6350 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6351 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6352 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6353 api_name);
6354 }
6355 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6356 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6357 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6358 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6359 "of elements of"
6360 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6361 api_name);
6362 }
6363 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6364 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6365 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6366 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6367 api_name);
6368 }
6369 }
6370 }
6371 }
6372 }
6373 return skip;
6374}
6375bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6376 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6377 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6378 bool skip = false;
6379 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6380 for (uint32_t i = 0; i < infoCount; ++i) {
6381 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6382 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6383 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6384 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6385 "scratchData.deviceAddress member must be a multiple of "
6386 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6387 }
6388 for (uint32_t k = 0; k < infoCount; ++k) {
6389 if (i == k) continue;
6390 bool found = false;
6391 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6392 skip |= LogError(
6393 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6394 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6395 "not be "
6396 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6397 i, k);
6398 found = true;
6399 }
6400 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6401 skip |= LogError(
6402 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
6403 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
6404 "not be "
6405 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6406 i, k);
6407 found = true;
6408 }
6409 if (found) break;
6410 }
6411 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6412 if (pInfos[i].pGeometries) {
6413 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6414 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6415 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6416 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6417 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6418 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6419 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6420 }
6421 } else {
6422 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6423 skip |=
6424 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6425 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6426 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6427 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6428 }
6429 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006430 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006431 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6432 skip |= LogError(
6433 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6434 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6435 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6436 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006437 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6438 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006439 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6440 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6441 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6442 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6443 }
6444 }
6445 } else if (pInfos[i].ppGeometries) {
6446 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6447 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6448 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6449 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6450 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6451 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6452 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6453 }
6454 } else {
6455 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6456 skip |=
6457 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6458 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6459 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6460 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6461 }
6462 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006463 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006464 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6465 skip |= LogError(
6466 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6467 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6468 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6469 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006470 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6471 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006472 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6473 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6474 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6475 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6476 }
6477 }
6478 }
6479 }
6480 }
6481 return skip;
6482}
6483
6484bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
6485 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6486 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
6487 const uint32_t *const *ppMaxPrimitiveCounts) const {
6488 bool skip = false;
6489 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
6490 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006491 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006492 if (!ray_tracing_acceleration_structure_features ||
6493 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
6494 skip |= LogError(
6495 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
6496 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
6497 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
6498 }
6499 for (uint32_t i = 0; i < infoCount; ++i) {
6500 if (pInfos[i].mode == VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR) {
6501 if (pInfos[i].srcAccelerationStructure == VK_NULL_HANDLE) {
6502 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03666",
6503 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, if its mode member is "
6504 "VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, its srcAccelerationStructure member must not be "
6505 "VK_NULL_HANDLE.");
6506 }
6507 }
6508 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6509 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6510 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
6511 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
6512 "scratchData.deviceAddress member must be a multiple of "
6513 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6514 }
6515 for (uint32_t k = 0; k < infoCount; ++k) {
6516 if (i == k) continue;
6517 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6518 skip |=
6519 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
6520 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
6521 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
6522 "any other element [%d) of pInfos.",
6523 i, k);
6524 break;
6525 }
6526 }
6527 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6528 if (pInfos[i].pGeometries) {
6529 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6530 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6531 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6532 skip |= LogError(
6533 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6534 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6535 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6536 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6537 }
6538 } else {
6539 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6540 skip |= LogError(
6541 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6542 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6543 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6544 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6545 }
6546 }
6547 }
6548 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6549 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6550 skip |= LogError(
6551 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6552 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6553 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6554 }
6555 }
6556 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6557 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
6558 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6559 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6560 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6561 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6562 }
6563 }
6564 } else if (pInfos[i].ppGeometries) {
6565 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6566 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6567 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6568 skip |= LogError(
6569 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6570 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6571 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6572 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6573 }
6574 } else {
6575 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6576 skip |= LogError(
6577 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6578 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6579 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6580 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6581 }
6582 }
6583 }
6584 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6585 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6586 skip |= LogError(
6587 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6588 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6589 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6590 }
6591 }
6592 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6593 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
6594 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6595 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6596 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6597 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6598 }
6599 }
6600 }
6601 }
6602 }
6603 return skip;
6604}
6605
6606bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
6607 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
6608 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6609 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6610 bool skip = false;
6611 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
6612 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006613 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006614 if (!ray_tracing_acceleration_structure_features ||
6615 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6616 skip |=
6617 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
6618 "vkBuildAccelerationStructuresKHR: The "
6619 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
6620 }
6621 for (uint32_t i = 0; i < infoCount; ++i) {
6622 for (uint32_t j = 0; j < infoCount; ++j) {
6623 if (i == j) continue;
6624 bool found = false;
6625 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6626 skip |= LogError(
6627 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6628 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
6629 "not be "
6630 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6631 i, j);
6632 found = true;
6633 }
6634 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6635 skip |= LogError(
6636 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
6637 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
6638 "not be "
6639 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6640 i, j);
6641 found = true;
6642 }
6643 if (found) break;
6644 }
6645 }
6646 return skip;
6647}
6648
6649bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
6650 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
6651 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
6652 bool skip = false;
6653 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
6654 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006655 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
6656 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006657 if (!(ray_tracing_pipeline_features || ray_query_features) ||
6658 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
6659 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
6660 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
6661 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
6662 }
6663 return skip;
6664}
sfricke-samsungecafb192021-01-17 08:21:14 -08006665
6666bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
6667 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
6668 const VkAllocationCallbacks *pAllocator,
6669 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
6670 bool skip = false;
6671 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
6672 if (private_data_features && private_data_features->privateData == VK_FALSE) {
6673 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
6674 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
6675 }
6676 return skip;
6677}