blob: cf7616f99e2af03a8dea6f57ce2720dddba0c635 [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 }
430 }
431
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700432 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700433 if (vulkan_12_features) {
434 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
435 while (current) {
436 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
437 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
438 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
439 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
440 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
441 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
442 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
443 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
444 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
445 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
446 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
447 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
448 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700449 skip |= LogError(
450 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700451 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
452 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
453 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
454 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
455 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
456 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
457 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
458 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
459 break;
460 }
461 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
462 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700463 // Check features are enabled if matching extension is passed in as well
464 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
465 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
466 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
467 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
468 skip |= LogError(
469 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
470 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
471 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
472 }
473 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
474 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
475 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
476 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
477 "is not VK_TRUE.",
478 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
479 }
480 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
481 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
482 skip |= LogError(
483 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
484 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
485 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
486 }
487 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
488 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
489 skip |= LogError(
490 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
491 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
492 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
493 }
494 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
495 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
496 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
497 skip |=
498 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
499 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
500 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
501 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
502 }
503 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700504 }
505
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600506 // Validate pCreateInfo->pQueueCreateInfos
507 if (pCreateInfo->pQueueCreateInfos) {
508 std::unordered_set<uint32_t> set;
509
510 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700511 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
512 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600513 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700514 skip |=
515 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
516 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
517 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
518 "index value.",
519 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600520 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700521 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
522 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
523 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
524 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600525 } else {
526 set.insert(requested_queue_family);
527 }
528
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700529 if (queue_create_info.pQueuePriorities != nullptr) {
530 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
531 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600532 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700533 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
534 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
535 "] (=%f) is not between 0 and 1 (inclusive).",
536 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600537 }
538 }
539 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700540
541 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700542 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700543 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700544 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700545 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700546 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700547 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700548 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700549 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700550 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700551 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
552 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
553 "protectedMemory feature being set as well.");
554 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600555 }
556 }
557
sfricke-samsung30a57412020-05-15 21:14:54 -0700558 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700559 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700560 VkBool32 variable_pointers = VK_FALSE;
561 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700562 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700563 variable_pointers = vulkan_11_features->variablePointers;
564 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700565 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700566 variable_pointers = variable_pointers_features->variablePointers;
567 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700568 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700569 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700570 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
571 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
572 }
573
sfricke-samsungfd76c342020-05-29 23:13:43 -0700574 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700575 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700576 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700577 VkBool32 multiview_geometry_shader = VK_FALSE;
578 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700579 if (vulkan_11_features) {
580 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700581 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
582 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700583 } else if (multiview_features) {
584 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700585 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
586 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700587 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700588 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700589 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
590 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
591 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700592 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700593 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
594 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
595 }
596
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600597 return skip;
598}
599
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500600bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700601 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700602 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
603 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
604 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600605 }
606
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700607 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600608}
609
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700610bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500611 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100612 bool skip = false;
613
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600614 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700615 skip |=
616 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600617
618 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
619 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
620 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
621 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700622 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
623 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
624 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600625 }
626
627 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
628 // queueFamilyIndexCount uint32_t values
629 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700630 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
631 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
632 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
633 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600634 }
635 }
636
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700637 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
638 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
639 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
640 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
641 }
642
643 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
644 skip |=
645 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
646 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
647 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
648 }
649
650 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
651 skip |=
652 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
653 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
654 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
655 }
656
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600657 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
658 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
659 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
660 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700661 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
662 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
663 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600664 }
665 }
666
667 return skip;
668}
669
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700670bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500671 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600672 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600673
674 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800675 const VkFormat image_format = pCreateInfo->format;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600676 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
677 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
678 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
679 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700680 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
681 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
682 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600683 }
684
685 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
686 // queueFamilyIndexCount uint32_t values
687 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700688 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
689 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
690 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
691 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600692 }
693 }
694
Dave Houlton413a6782018-05-22 13:01:54 -0600695 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700696 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600697 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700698 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600699 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700700 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600701
Dave Houlton413a6782018-05-22 13:01:54 -0600702 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700703 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600704 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700705 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600706
Dave Houlton130c0212018-01-29 13:39:56 -0700707 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700708 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
709 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700710 skip |= LogError(
711 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600712 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
713 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700714 }
715
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600716 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100717 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
718 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700719 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
720 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
721 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600722 }
723
724 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100725 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
726 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700727 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
728 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
729 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
730 ") are not equal.",
731 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100732 }
733
734 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700735 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
736 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
737 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
738 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100739 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600740 }
741
742 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700743 skip |= LogError(
744 device, "VUID-VkImageCreateInfo-imageType-00957",
745 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600746 }
747 }
748
Dave Houlton130c0212018-01-29 13:39:56 -0700749 // 3D image may have only 1 layer
750 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700751 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
752 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700753 }
754
Dave Houlton130c0212018-01-29 13:39:56 -0700755 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
756 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
757 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
758 // At least one of the legal attachment bits must be set
759 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700760 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
761 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700762 }
763 // No flags other than the legal attachment bits may be set
764 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
765 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700766 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
767 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700768 }
769 }
770
Jeff Bolzef40fec2018-09-01 22:04:34 -0500771 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700772 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500773 // Max mip levels is different for corner-sampled images vs normal images.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700774 uint32_t max_mip_levels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
775 ? static_cast<uint32_t>(ceil(log2(max_dim)))
776 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
777 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600778 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700779 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
780 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
781 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600782 }
783
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600784 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700785 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
786 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
787 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600788 }
789
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700790 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700791 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
792 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
793 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100794 }
795
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700796 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
797 skip |= LogError(
798 device, "VUID-VkImageCreateInfo-flags-01924",
799 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
800 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
801 }
802
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600803 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
804 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
805 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
806 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700807 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
808 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
809 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600810 }
811
812 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
813 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
814 // Linear tiling is unsupported
815 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700816 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700817 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
818 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600819 }
820
821 // Sparse 1D image isn't valid
822 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700823 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
824 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600825 }
826
827 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700828 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700829 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
830 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
831 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600832 }
833
834 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700835 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700836 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
837 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
838 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600839 }
840
841 // Multi-sample 2D image when device doesn't support it
842 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700843 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600844 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700845 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
846 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
847 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700848 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600849 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700850 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
851 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
852 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700853 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600854 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700855 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
856 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
857 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700858 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600859 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700860 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
861 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
862 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600863 }
864 }
865 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500866
Jeff Bolz9af91c52018-09-01 21:53:57 -0500867 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
868 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700869 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
870 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
871 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500872 }
873 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700874 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
875 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
876 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500877 }
878 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700879 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
880 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
881 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500882 }
883 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500884
885 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600886 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700887 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
888 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
889 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500890 }
891
sfricke-samsung61a57c02021-01-10 21:35:12 -0800892 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700893 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
894 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800895 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
896 "depth/stencil format.",
897 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500898 }
899
Dave Houlton142c4cb2018-10-17 15:04:41 -0600900 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700901 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
902 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
903 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
904 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500905 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600906 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700907 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
908 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
909 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
910 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500911 }
912 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500913
sfricke-samsung8f658d42020-05-03 20:12:24 -0700914 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -0800915 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -0700916 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
917 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800918 "format (%s) must be a depth or depth/stencil format.",
919 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -0700920 }
921
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700922 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500923 if (image_stencil_struct != nullptr) {
924 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
925 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
926 // No flags other than the legal attachment bits may be set
927 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
928 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700929 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
930 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
931 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
932 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500933 }
934 }
935
sfricke-samsung61a57c02021-01-10 21:35:12 -0800936 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -0500937 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
938 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
939 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700940 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
941 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
942 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
943 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500944 }
945
946 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
947 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700948 LogError(device, "VUID-VkImageCreateInfo-format-02537",
949 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
950 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
951 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500952 }
953 }
954
955 if (!physical_device_features.shaderStorageImageMultisample &&
956 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
957 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
958 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700959 LogError(device, "VUID-VkImageCreateInfo-format-02538",
960 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
961 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
962 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500963 }
964
965 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
966 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700967 skip |= LogError(
968 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500969 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
970 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
971 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
972 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
973 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700974 skip |= LogError(
975 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500976 "vkCreateImage(): Depth-stencil image in which usage does not include "
977 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
978 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
979 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
980 }
981
982 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
983 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700984 skip |= LogError(
985 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500986 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
987 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
988 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
989 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
990 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700991 skip |= LogError(
992 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500993 "vkCreateImage(): Depth-stencil image in which usage does not include "
994 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
995 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
996 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
997 }
998 }
999 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001000
1001 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1002 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1003 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1004 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1005 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1006 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001007
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001008 std::vector<uint64_t> image_create_drm_format_modifiers;
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001009 if (device_extensions.vk_ext_image_drm_format_modifier) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001010 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1011 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001012 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1013 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1014 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1015 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1016 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1017 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1018 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001019 } else if (drm_format_mod_list != nullptr) {
1020 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1021 } else if (drm_format_mod_list != nullptr) {
1022 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1023 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1024 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001025 }
1026 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1027 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1028 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1029 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1030 "in the pNext chain");
1031 }
1032 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001033
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001034 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001035 bool image_create_maybe_linear = false;
1036 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1037 image_create_maybe_linear = true;
1038 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1039 image_create_maybe_linear = false;
1040 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1041 image_create_maybe_linear =
1042 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001043 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001044 }
1045
1046 // If multi-sample, validate type, usage, tiling and mip levels.
1047 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
1048 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
1049 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1050 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1051 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1052 }
1053
1054 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
1055 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1056 image_create_maybe_linear)) {
1057 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1058 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1059 }
1060
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001061 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1062 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1063 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1064 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1065 "imageType must be VK_IMAGE_TYPE_2D.");
1066 }
1067 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1068 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1069 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1070 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1071 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001072 }
1073 if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
1074 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1075 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1076 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1077 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1078 }
1079 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1080 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1081 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1082 "imageType must be VK_IMAGE_TYPE_2D.");
1083 }
1084 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
1085 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1086 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1087 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1088 }
1089 if (pCreateInfo->mipLevels != 1) {
1090 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1091 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1092 pCreateInfo->mipLevels);
1093 }
1094 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001095
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001096 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001097 if (swapchain_create_info != nullptr) {
1098 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1099 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1100 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1101 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1102 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1103 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1104
1105 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1106 // also implicitly forces the check above that extent.depth is 1
1107 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1108 string_VkImageType(pCreateInfo->imageType));
1109 }
1110 if (pCreateInfo->mipLevels != 1) {
1111 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1112 pCreateInfo->mipLevels);
1113 }
1114 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1115 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1116 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1117 }
1118 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1119 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1120 base_message, string_VkImageTiling(pCreateInfo->tiling));
1121 }
1122 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1123 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1124 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1125 }
1126 const VkImageCreateFlags valid_flags =
1127 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001128 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001129 if ((pCreateInfo->flags & ~valid_flags) != 0) {
1130 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
1131 pCreateInfo->flags);
1132 }
1133 }
1134 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001135
1136 // If Chroma subsampled format ( _420_ or _422_ )
1137 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1138 skip |=
1139 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1140 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1141 ") must be a multiple of 2.",
1142 string_VkFormat(image_format), pCreateInfo->extent.width);
1143 }
1144 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1145 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1146 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1147 ") must be a multiple of 2.",
1148 string_VkFormat(image_format), pCreateInfo->extent.height);
1149 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001150 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001151
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001152 return skip;
1153}
1154
Jeff Bolz99e3f632020-03-24 22:59:22 -05001155bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1156 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1157 bool skip = false;
1158
1159 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001160 // Validate feature set if using CUBE_ARRAY
1161 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1162 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1163 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1164 "enabling the imageCubeArray feature.");
1165 }
1166
Jeff Bolz99e3f632020-03-24 22:59:22 -05001167 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1168 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1169 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001170 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001171 pCreateInfo->subresourceRange.layerCount);
1172 }
1173 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001174 skip |= LogError(
1175 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1176 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1177 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001178 }
1179 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001180
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001181 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001182 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1183 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1184 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1185 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1186 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1187 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1188 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1189 }
1190 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1191 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1192 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1193 "not an ASTC format.",
1194 string_VkFormat(pCreateInfo->format));
1195 }
1196 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001197
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001198 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001199 if (ycbcr_conversion != nullptr) {
1200 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1201 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1202 skip |= LogError(
1203 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1204 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1205 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1206 "r swizzle = %s\n"
1207 "g swizzle = %s\n"
1208 "b swizzle = %s\n"
1209 "a swizzle = %s\n",
1210 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1211 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1212 }
1213 }
1214 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001215 }
1216 return skip;
1217}
1218
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001219bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001220 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001221 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001222
1223 // Note: for numerical correctness
1224 // - float comparisons should expect NaN (comparison always false).
1225 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1226
1227 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001228 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001229 if (v1_f <= 0.0f) return true;
1230
1231 float intpart;
1232 const float fract = modff(v1_f, &intpart);
1233
1234 assert(std::numeric_limits<float>::radix == 2);
1235 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1236 if (intpart >= u32_max_plus1) return false;
1237
1238 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001239 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001240 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001241 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001242 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001243 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001244 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001245 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001246 };
1247
1248 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1249 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1250 return (v1_f <= v2_f);
1251 };
1252
1253 // width
1254 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001255 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001256
1257 if (!(viewport.width > 0.0f)) {
1258 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001259 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1260 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001261 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1262 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001263 skip |= LogError(object, "VUID-VkViewport-width-01771",
1264 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1265 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001266 }
1267
1268 // height
1269 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001270 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001271 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001272
1273 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1274 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001275 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1276 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001277 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1278 height_healthy = false;
1279
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001280 skip |= LogError(object, "VUID-VkViewport-height-01773",
1281 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1282 ").",
1283 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001284 }
1285
1286 // x
1287 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001288 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001289 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001290 skip |= LogError(object, "VUID-VkViewport-x-01774",
1291 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1292 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001293 }
1294
1295 // x + width
1296 if (x_healthy && width_healthy) {
1297 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001298 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001299 skip |= LogError(
1300 object, "VUID-VkViewport-x-01232",
1301 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1302 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1303 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001304 }
1305 }
1306
1307 // y
1308 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001309 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001310 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001311 skip |= LogError(object, "VUID-VkViewport-y-01775",
1312 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1313 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001314 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001315 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001316 skip |= LogError(object, "VUID-VkViewport-y-01776",
1317 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1318 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001319 }
1320
1321 // y + height
1322 if (y_healthy && height_healthy) {
1323 const float boundary = viewport.y + viewport.height;
1324
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001325 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001326 skip |= LogError(object, "VUID-VkViewport-y-01233",
1327 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1328 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1329 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001330 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001331 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001332 LogError(object, "VUID-VkViewport-y-01777",
1333 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1334 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1335 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001336 }
1337 }
1338
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001339 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001340 // minDepth
1341 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001342 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001343
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001344 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1345 "[0.0, 1.0] range.",
1346 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001347 }
1348
1349 // maxDepth
1350 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001351 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001352
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001353 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1354 "[0.0, 1.0] range.",
1355 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001356 }
1357 }
1358
1359 return skip;
1360}
1361
Dave Houlton142c4cb2018-10-17 15:04:41 -06001362struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001363 VkShadingRatePaletteEntryNV shadingRate;
1364 uint32_t width;
1365 uint32_t height;
1366};
1367
1368// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001369static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001370 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1371 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1372 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1373 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1374 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1375 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001376};
1377
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001378bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001379 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001380
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001381 SampleOrderInfo *sample_order_info;
1382 uint32_t info_idx = 0;
1383 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1384 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1385 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001386 break;
1387 }
1388 }
1389
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001390 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001391 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1392 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1393 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001394 return skip;
1395 }
1396
Dave Houlton142c4cb2018-10-17 15:04:41 -06001397 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001398 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001399 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1400 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1401 ") must "
1402 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1403 "is set in framebufferNoAttachmentsSampleCounts.",
1404 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001405 }
1406
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001407 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001408 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1409 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1410 ") must "
1411 "be equal to the product of sampleCount (=%" PRIu32
1412 "), the fragment width for shadingRate "
1413 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001414 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001415 }
1416
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001417 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001418 skip |= LogError(
1419 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001420 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1421 ") must "
1422 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001423 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001424 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001425
1426 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001427 // the first width*height*sampleCount bits to all be set. Note: There is no
1428 // guarantee that 64 bits is enough, but practically it's unlikely for an
1429 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001430 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001431 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001432 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001433 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1434 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001435 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1436 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001437 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001438 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001439 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1440 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001441 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001442 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001443 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1444 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001445 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001446 uint32_t idx =
1447 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1448 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001449 }
1450
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001451 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1452 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001453 skip |= LogError(
1454 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001455 "The array pSampleLocations must contain exactly one entry for "
1456 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001457 }
1458
1459 return skip;
1460}
1461
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001462bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1463 uint32_t createInfoCount,
1464 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1465 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001466 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001467 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001468
1469 if (pCreateInfos != nullptr) {
1470 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001471 bool has_dynamic_viewport = false;
1472 bool has_dynamic_scissor = false;
1473 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001474 bool has_dynamic_depth_bias = false;
1475 bool has_dynamic_blend_constant = false;
1476 bool has_dynamic_depth_bounds = false;
1477 bool has_dynamic_stencil_compare = false;
1478 bool has_dynamic_stencil_write = false;
1479 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001480 bool has_dynamic_viewport_w_scaling_nv = false;
1481 bool has_dynamic_discard_rectangle_ext = false;
1482 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001483 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001484 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001485 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001486 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001487 bool has_dynamic_cull_mode = false;
1488 bool has_dynamic_front_face = false;
1489 bool has_dynamic_primitive_topology = false;
1490 bool has_dynamic_viewport_with_count = false;
1491 bool has_dynamic_scissor_with_count = false;
1492 bool has_dynamic_vertex_input_binding_stride = false;
1493 bool has_dynamic_depth_test_enable = false;
1494 bool has_dynamic_depth_write_enable = false;
1495 bool has_dynamic_depth_compare_op = false;
1496 bool has_dynamic_depth_bounds_test_enable = false;
1497 bool has_dynamic_stencil_test_enable = false;
1498 bool has_dynamic_stencil_op = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07001499 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
1500 skip |=
1501 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
1502 "vkCreateGraphicsPipelines: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR");
1503 }
Petr Kraus299ba622017-11-24 03:09:03 +01001504 if (pCreateInfos[i].pDynamicState != nullptr) {
1505 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1506 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1507 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001508 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1509 if (has_dynamic_viewport == true) {
1510 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1511 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1512 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1513 i);
1514 }
1515 has_dynamic_viewport = true;
1516 }
1517 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1518 if (has_dynamic_scissor == true) {
1519 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1520 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1521 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1522 i);
1523 }
1524 has_dynamic_scissor = true;
1525 }
1526 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1527 if (has_dynamic_line_width == true) {
1528 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1529 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1530 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1531 i);
1532 }
1533 has_dynamic_line_width = true;
1534 }
1535 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1536 if (has_dynamic_depth_bias == true) {
1537 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1538 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1539 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1540 i);
1541 }
1542 has_dynamic_depth_bias = true;
1543 }
1544 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1545 if (has_dynamic_blend_constant == true) {
1546 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1547 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1548 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1549 i);
1550 }
1551 has_dynamic_blend_constant = true;
1552 }
1553 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1554 if (has_dynamic_depth_bounds == true) {
1555 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1556 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1557 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1558 i);
1559 }
1560 has_dynamic_depth_bounds = true;
1561 }
1562 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1563 if (has_dynamic_stencil_compare == true) {
1564 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1565 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1566 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1567 i);
1568 }
1569 has_dynamic_stencil_compare = true;
1570 }
1571 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1572 if (has_dynamic_stencil_write == true) {
1573 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1574 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1575 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1576 i);
1577 }
1578 has_dynamic_stencil_write = true;
1579 }
1580 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1581 if (has_dynamic_stencil_reference == true) {
1582 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1583 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1584 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1585 i);
1586 }
1587 has_dynamic_stencil_reference = true;
1588 }
1589 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1590 if (has_dynamic_viewport_w_scaling_nv == true) {
1591 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1592 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1593 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1594 i);
1595 }
1596 has_dynamic_viewport_w_scaling_nv = true;
1597 }
1598 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1599 if (has_dynamic_discard_rectangle_ext == true) {
1600 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1601 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1602 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1603 i);
1604 }
1605 has_dynamic_discard_rectangle_ext = true;
1606 }
1607 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1608 if (has_dynamic_sample_locations_ext == true) {
1609 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1610 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1611 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1612 i);
1613 }
1614 has_dynamic_sample_locations_ext = true;
1615 }
1616 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1617 if (has_dynamic_exclusive_scissor_nv == true) {
1618 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1619 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1620 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1621 i);
1622 }
1623 has_dynamic_exclusive_scissor_nv = true;
1624 }
1625 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1626 if (has_dynamic_shading_rate_palette_nv == true) {
1627 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1628 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1629 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1630 i);
1631 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001632 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001633 }
1634 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1635 if (has_dynamic_viewport_course_sample_order_nv == true) {
1636 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1637 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1638 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1639 i);
1640 }
1641 has_dynamic_viewport_course_sample_order_nv = true;
1642 }
1643 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1644 if (has_dynamic_line_stipple == true) {
1645 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1646 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1647 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1648 i);
1649 }
1650 has_dynamic_line_stipple = true;
1651 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001652 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1653 if (has_dynamic_cull_mode) {
1654 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1655 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1656 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1657 i);
1658 }
1659 has_dynamic_cull_mode = true;
1660 }
1661 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1662 if (has_dynamic_front_face) {
1663 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1664 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1665 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1666 i);
1667 }
1668 has_dynamic_front_face = true;
1669 }
1670 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1671 if (has_dynamic_primitive_topology) {
1672 skip |= LogError(
1673 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1674 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1675 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1676 i);
1677 }
1678 has_dynamic_primitive_topology = true;
1679 }
1680 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1681 if (has_dynamic_viewport_with_count) {
1682 skip |= LogError(
1683 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1684 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1685 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1686 i);
1687 }
1688 has_dynamic_viewport_with_count = true;
1689 }
1690 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1691 if (has_dynamic_scissor_with_count) {
1692 skip |= LogError(
1693 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1694 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1695 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1696 i);
1697 }
1698 has_dynamic_scissor_with_count = true;
1699 }
1700 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1701 if (has_dynamic_vertex_input_binding_stride) {
1702 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1703 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1704 "listed twice in the "
1705 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1706 i);
1707 }
1708 has_dynamic_vertex_input_binding_stride = true;
1709 }
1710 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1711 if (has_dynamic_depth_test_enable) {
1712 skip |= LogError(
1713 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1714 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1715 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1716 i);
1717 }
1718 has_dynamic_depth_test_enable = true;
1719 }
1720 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1721 if (has_dynamic_depth_write_enable) {
1722 skip |= LogError(
1723 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1724 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1725 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1726 i);
1727 }
1728 has_dynamic_depth_write_enable = true;
1729 }
1730 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1731 if (has_dynamic_depth_compare_op) {
1732 skip |=
1733 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1734 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1735 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1736 i);
1737 }
1738 has_dynamic_depth_compare_op = true;
1739 }
1740 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1741 if (has_dynamic_depth_bounds_test_enable) {
1742 skip |= LogError(
1743 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1744 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1745 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1746 i);
1747 }
1748 has_dynamic_depth_bounds_test_enable = true;
1749 }
1750 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1751 if (has_dynamic_stencil_test_enable) {
1752 skip |= LogError(
1753 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1754 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1755 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1756 i);
1757 }
1758 has_dynamic_stencil_test_enable = true;
1759 }
1760 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1761 if (has_dynamic_stencil_op) {
1762 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1763 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1764 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1765 i);
1766 }
1767 has_dynamic_stencil_op = true;
1768 }
Petr Kraus299ba622017-11-24 03:09:03 +01001769 }
1770 }
1771
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001772 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04001773 if ((feedback_struct != nullptr) &&
1774 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001775 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1776 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1777 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1778 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1779 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001780 }
1781
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001782 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001783
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001784 // Collect active stages and other information
1785 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001786 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001787 bool has_eval = false;
1788 bool has_control = false;
1789 if (pCreateInfos[i].pStages != nullptr) {
1790 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1791 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1792
1793 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1794 has_control = true;
1795 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1796 has_eval = true;
1797 }
1798
1799 skip |= validate_string(
1800 "vkCreateGraphicsPipelines",
1801 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1802 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1803 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001804 }
1805
1806 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1807 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1808 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1809 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1810 pCreateInfos[i].pTessellationState,
1811 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1812 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1813
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001814 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001815 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1816
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001817 skip |= validate_struct_pnext(
1818 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1819 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
1820 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
1821 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
1822 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1823 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001824
1825 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1826 pCreateInfos[i].pTessellationState->flags,
1827 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1828 }
1829
1830 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1831 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1832 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1833 pCreateInfos[i].pInputAssemblyState,
1834 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1835 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1836
1837 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1838 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001839 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001840
1841 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1842 pCreateInfos[i].pInputAssemblyState->flags,
1843 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1844
1845 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1846 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1847 pCreateInfos[i].pInputAssemblyState->topology,
1848 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1849
1850 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1851 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1852 }
1853
1854 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001855 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001856
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001857 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001858 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1859 "vkCreateGraphicsPipelines: pararameter "
1860 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1861 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001862 }
1863
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001864 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001865 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1866 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1867 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1868 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001869 allowed_structs_vk_pipeline_vertex_input_state_create_info,
1870 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08001871 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001872 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1873 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001874 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001875 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1876 skip |=
1877 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1878 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1879 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1880 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1881 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1882
1883 skip |= validate_array(
1884 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1885 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1886 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1887 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1888
1889 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001890 for (uint32_t vertex_binding_description_index = 0;
1891 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1892 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001893 skip |= validate_ranged_enum(
1894 "vkCreateGraphicsPipelines",
1895 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1896 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001897 pCreateInfos[i]
1898 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
1899 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001900 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1901 }
1902 }
1903
1904 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001905 for (uint32_t vertex_attribute_description_index = 0;
1906 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1907 ++vertex_attribute_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001908 skip |= validate_ranged_enum(
1909 "vkCreateGraphicsPipelines",
1910 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1911 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001912 pCreateInfos[i]
1913 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
1914 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001915 "VUID-VkVertexInputAttributeDescription-format-parameter");
1916 }
1917 }
1918
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001919 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001920 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1921 "vkCreateGraphicsPipelines: pararameter "
1922 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1923 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1924 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001925 }
1926
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001927 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001928 skip |=
1929 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1930 "vkCreateGraphicsPipelines: pararameter "
1931 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1932 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1933 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001934 }
1935
1936 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001937 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1938 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001939 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1940 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001941 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1942 "vkCreateGraphicsPipelines: parameter "
1943 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1944 "(%" PRIu32 ") is not distinct.",
1945 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001946 }
1947 vertex_bindings.insert(vertex_bind_desc.binding);
1948
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001949 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001950 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1951 "vkCreateGraphicsPipelines: parameter "
1952 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1953 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1954 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001955 }
1956
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001957 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001958 skip |=
1959 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1960 "vkCreateGraphicsPipelines: parameter "
1961 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1962 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1963 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001964 }
1965 }
1966
Peter Kohautc7d9d392018-07-15 00:34:07 +02001967 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001968 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1969 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001970 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1971 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001972 skip |= LogError(
1973 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001974 "vkCreateGraphicsPipelines: parameter "
1975 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1976 i, d, vertex_attrib_desc.location);
1977 }
1978 attribute_locations.insert(vertex_attrib_desc.location);
1979
1980 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1981 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001982 skip |= LogError(
1983 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001984 "vkCreateGraphicsPipelines: parameter "
1985 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1986 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1987 i, d, vertex_attrib_desc.binding, i);
1988 }
1989
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001990 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001991 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1992 "vkCreateGraphicsPipelines: parameter "
1993 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1994 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1995 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001996 }
1997
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001998 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001999 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2000 "vkCreateGraphicsPipelines: parameter "
2001 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
2002 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2003 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002004 }
2005
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002006 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002007 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2008 "vkCreateGraphicsPipelines: parameter "
2009 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
2010 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
2011 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002012 }
2013 }
2014 }
2015
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002016 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2017 if (has_control && has_eval) {
2018 if (pCreateInfos[i].pTessellationState == nullptr) {
2019 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
2020 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
2021 "shader stage and a tessellation evaluation shader stage, "
2022 "pCreateInfos[%d].pTessellationState must not be NULL.",
2023 i, i);
2024 } else {
2025 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2026 skip |= validate_struct_pnext(
2027 "vkCreateGraphicsPipelines",
2028 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2029 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2030 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2031 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002032
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002033 skip |= validate_reserved_flags(
2034 "vkCreateGraphicsPipelines",
2035 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2036 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002037
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002038 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2039 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2040 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2041 "vkCreateGraphicsPipelines: invalid parameter "
2042 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
2043 "should be >0 and <=%u.",
2044 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2045 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002046 }
2047 }
2048 }
2049
2050 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2051 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2052 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2053 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002054 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2055 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2056 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2057 "].pViewportState (=NULL) is not a valid pointer.",
2058 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002059 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002060 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2061
2062 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002063 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2064 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2065 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2066 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002067 }
2068
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002069 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002070 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002071 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2072 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002073 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2074 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002075 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002076 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002077 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002078 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002079 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002080 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2081 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002082 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2083 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2084 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002085 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002086
2087 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002088 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002089 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002090 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002091
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002092 auto exclusive_scissor_struct =
2093 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2094 auto shading_rate_image_struct =
2095 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2096 auto coarse_sample_order_struct =
2097 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002098 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002099 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002100 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002101 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002102
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002103 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002104 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002105 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2106 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2107 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2108 ") is not 1.",
2109 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002110 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002111
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002112 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002113 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2114 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2115 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2116 ") is not 1.",
2117 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002118 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002119
Dave Houlton142c4cb2018-10-17 15:04:41 -06002120 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2121 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002122 skip |= LogError(
2123 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2124 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2125 "disabled, but pCreateInfos[%" PRIu32
2126 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2127 ") is not 1.",
2128 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002129 }
2130
Jeff Bolz9af91c52018-09-01 21:53:57 -05002131 if (shading_rate_image_struct &&
2132 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002133 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2134 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2135 "disabled, but pCreateInfos[%" PRIu32
2136 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2137 ") is neither 0 nor 1.",
2138 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002139 }
2140
Petr Krausa6103552017-11-16 21:21:58 +01002141 } else { // multiViewport enabled
2142 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002143 if (!has_dynamic_viewport_with_count) {
2144 skip |= LogError(
2145 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2146 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2147 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002148 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002149 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2150 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2151 "].pViewportState->viewportCount (=%" PRIu32
2152 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2153 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002154 } else if (has_dynamic_viewport_with_count) {
2155 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2156 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2157 "].pViewportState->viewportCount (=%" PRIu32
2158 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2159 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002160 }
Petr Krausa6103552017-11-16 21:21:58 +01002161
2162 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002163 if (!has_dynamic_scissor_with_count) {
2164 skip |= LogError(
2165 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2166 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2167 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002168 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002169 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2170 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2171 "].pViewportState->scissorCount (=%" PRIu32
2172 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2173 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002174 } else if (has_dynamic_scissor_with_count) {
2175 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2176 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2177 "].pViewportState->scissorCount (=%" PRIu32
2178 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2179 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002180 }
2181 }
2182
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002183 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002184 skip |=
2185 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2186 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2187 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2188 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002189 }
2190
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002191 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002192 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2193 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2194 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2195 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2196 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002197 }
2198
Piers Daniell39842ee2020-07-10 16:42:33 -06002199 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2200 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002201 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2202 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2203 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2204 "].pViewportState->viewportCount (=%" PRIu32 ").",
2205 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002206 }
2207
Dave Houlton142c4cb2018-10-17 15:04:41 -06002208 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002209 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002210 skip |=
2211 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2212 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2213 ") must be zero or identical to pCreateInfos[%" PRIu32
2214 "].pViewportState->viewportCount (=%" PRIu32 ").",
2215 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002216 }
2217
Dave Houlton142c4cb2018-10-17 15:04:41 -06002218 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002219 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002220 skip |= LogError(
2221 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002222 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2223 "] "
2224 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2225 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2226 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002227 }
2228
Petr Krausa6103552017-11-16 21:21:58 +01002229 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002230 skip |= LogError(
2231 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002232 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2233 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002234 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2235 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002236 }
2237
2238 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002239 skip |= LogError(
2240 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002241 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2242 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002243 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2244 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002245 }
2246
Jeff Bolz3e71f782018-08-29 23:15:45 -05002247 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002248 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2249 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2250 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002251 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002252 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2253 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2254 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2255 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002256 }
2257
Jeff Bolz9af91c52018-09-01 21:53:57 -05002258 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002259 shading_rate_image_struct->viewportCount > 0 &&
2260 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002261 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002262 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002263 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002264 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2265 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002266 i, i);
2267 }
2268
Chris Mayer328d8212018-12-11 14:16:18 +01002269 if (vp_swizzle_struct) {
2270 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002271 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2272 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2273 " does "
2274 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2275 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002276 }
2277 }
2278
Petr Krausb3fcdb42018-01-09 22:09:09 +01002279 // validate the VkViewports
2280 if (!has_dynamic_viewport && viewport_state.pViewports) {
2281 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2282 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002283 const char *fn_name = "vkCreateGraphicsPipelines";
2284 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2285 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2286 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002287 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002288 }
2289 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002290
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002291 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002292 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2293 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2294 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2295 "VK_NV_clip_space_w_scaling extension is not enabled.",
2296 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002297 }
2298
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002299 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002300 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2301 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2302 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2303 "VK_EXT_discard_rectangles extension is not enabled.",
2304 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002305 }
2306
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002307 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002308 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2309 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2310 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2311 "VK_EXT_sample_locations extension is not enabled.",
2312 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002313 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002314
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002315 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002316 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2317 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2318 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2319 "VK_NV_scissor_exclusive extension is not enabled.",
2320 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002321 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002322
2323 if (coarse_sample_order_struct &&
2324 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2325 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002326 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2327 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2328 "] "
2329 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2330 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2331 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002332 }
2333
2334 if (coarse_sample_order_struct) {
2335 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002336 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002337 }
2338 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002339
2340 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2341 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002342 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2343 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2344 "] "
2345 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2346 ") "
2347 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2348 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002349 }
2350 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002351 skip |= LogError(
2352 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002353 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2354 "] "
2355 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2356 i);
2357 }
2358 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002359 }
2360
2361 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002362 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2363 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2364 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2365 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002366 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002367 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002368 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002369 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2370 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002371 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002372 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002373 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002374 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002375 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002376 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002377 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002378 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2379 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002380
2381 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002382 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002383 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002384 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002385
2386 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002387 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002388 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2389 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2390
2391 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002392 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002393 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2394 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002395 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002396 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002397
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002398 skip |= validate_flags(
2399 "vkCreateGraphicsPipelines",
2400 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2401 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002402 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002403
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002404 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002405 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002406 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2407 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2408
2409 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002410 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002411 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2412 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2413
2414 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002415 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002416 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2417 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2418 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002419 }
John Zulauf7acac592017-11-06 11:15:53 -07002420 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002421 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002422 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2423 "vkCreateGraphicsPipelines(): parameter "
2424 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2425 i);
John Zulauf7acac592017-11-06 11:15:53 -07002426 }
2427 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2428 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2429 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002430 skip |= LogError(
2431 device,
2432
Dave Houlton413a6782018-05-22 13:01:54 -06002433 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002434 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002435 }
2436 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002437
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002438 const auto *line_state =
2439 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002440
2441 if (line_state) {
2442 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2443 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2444 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2445 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002446 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2447 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2448 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2449 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002450 }
2451 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2452 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002453 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2454 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2455 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2456 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002457 }
2458 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2459 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002460 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2461 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2462 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2463 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002464 }
2465 }
2466 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2467 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2468 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002469 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2470 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2471 "range [1,256].",
2472 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002473 }
2474 }
2475 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002476 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002477 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2478 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002479 skip |=
2480 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2481 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2482 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2483 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002484 }
2485 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2486 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002487 skip |=
2488 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2489 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2490 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2491 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002492 }
2493 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2494 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002495 skip |=
2496 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2497 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2498 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2499 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002500 }
2501 if (line_state->stippledLineEnable) {
2502 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2503 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002504 skip |=
2505 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2506 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2507 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2508 "stippledRectangularLines feature.",
2509 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002510 }
2511 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2512 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002513 skip |=
2514 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2515 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2516 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2517 "stippledBresenhamLines feature.",
2518 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002519 }
2520 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2521 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002522 skip |=
2523 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2524 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2525 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2526 "stippledSmoothLines feature.",
2527 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002528 }
2529 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2530 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002531 skip |=
2532 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2533 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2534 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2535 "stippledRectangularLines and strictLines features.",
2536 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002537 }
2538 }
2539 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002540 }
2541
Petr Krause91f7a12017-12-14 20:57:36 +01002542 bool uses_color_attachment = false;
2543 bool uses_depthstencil_attachment = false;
2544 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002545 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002546 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2547 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002548 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002549 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002550 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002551 }
2552 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002553 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002554 }
Petr Krause91f7a12017-12-14 20:57:36 +01002555 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002556 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002557 }
2558
2559 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002560 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002561 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002562 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002563 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002564 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002565
2566 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002567 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002568 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002569 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002570
2571 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002572 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002573 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2574 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2575
2576 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002577 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002578 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2579 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2580
2581 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002582 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002583 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2584 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002585 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002586
2587 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002588 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002589 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2590 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2591
2592 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002593 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002594 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2595 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2596
2597 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002598 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002599 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2600 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002601 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002602
2603 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002604 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002605 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2606 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002607 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002608
2609 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002610 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002611 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2612 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002613 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002614
2615 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002616 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002617 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2618 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002619 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002620
2621 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002622 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002623 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2624 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002625 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002626
2627 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002628 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002629 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2630 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002631 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002632
2633 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002634 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002635 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2636 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002637 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002638
2639 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002640 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002641 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2642 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002643 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002644
2645 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002646 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002647 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2648 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2649 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002650 }
2651 }
2652
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002653 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002654 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2655
Petr Krause91f7a12017-12-14 20:57:36 +01002656 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002657 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2658 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2659 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2660 pCreateInfos[i].pColorBlendState,
2661 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2662 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2663
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002664 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002665 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002666 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2667 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002668 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2669 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002670 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2671 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002672
2673 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002674 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002675 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002676 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002677
2678 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002679 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002680 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2681 pCreateInfos[i].pColorBlendState->logicOpEnable);
2682
2683 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002684 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002685 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2686 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002687 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002688 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002689
2690 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002691 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
2692 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002693 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002694 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002695 ParameterName::IndexVector{i, attachment_index}),
2696 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002697
2698 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002699 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002700 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002701 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002702 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002703 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002704 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002705
2706 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002707 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002708 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002709 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002710 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002711 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002712 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002713
2714 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002715 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002716 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002717 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002718 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002719 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002720 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002721
2722 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002723 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002724 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002725 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002726 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002727 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002728 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
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].dstAlphaBlendFactor",
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].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002736 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-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].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002741 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002742 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002743 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002744 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002745
2746 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002747 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002748 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002749 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002750 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002751 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002752 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002753 }
2754 }
2755
2756 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002757 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002758 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2759 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2760 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002761 }
2762
2763 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2764 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2765 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002766 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002767 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002768 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2769 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002770 }
2771 }
2772 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002773
Petr Kraus9752aae2017-11-24 03:05:50 +01002774 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2775 if (pCreateInfos[i].basePipelineIndex != -1) {
2776 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002777 skip |=
2778 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002779 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002780 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002781 "and pCreateInfos->basePipelineIndex is not -1.",
2782 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002783 }
2784 }
2785
Petr Kraus9752aae2017-11-24 03:05:50 +01002786 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2787 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002788 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002789 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002790 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002791 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2792 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002793 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002794 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002795 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002796 skip |=
2797 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2798 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2799 "index into the pCreateInfos array, of size %d.",
2800 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002801 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002802 }
2803 }
2804
sfricke-samsung898cf222020-05-15 23:10:19 -07002805 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2806 skip |= LogError(
2807 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2808 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE",
2809 i);
2810 }
2811
Petr Kraus9752aae2017-11-24 03:05:50 +01002812 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002813 if (!device_extensions.vk_nv_fill_rectangle) {
2814 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2815 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002816 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2817 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2818 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2819 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002820 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2821 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07002822 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002823 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002824 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2825 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2826 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002827 }
2828 } else {
2829 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2830 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2831 (physical_device_features.fillModeNonSolid == false)) {
2832 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002833 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2834 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002835 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2836 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2837 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002838 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002839 }
Petr Kraus299ba622017-11-24 03:09:03 +01002840
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002841 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002842 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002843 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2844 "The line width state is static (pCreateInfos[%" PRIu32
2845 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2846 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2847 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2848 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002849 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002850 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002851 }
2852 }
2853
2854 return skip;
2855}
2856
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002857bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2858 uint32_t createInfoCount,
2859 const VkComputePipelineCreateInfo *pCreateInfos,
2860 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002861 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002862 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002863 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002864 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002865 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002866 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002867 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04002868 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002869 skip |=
2870 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2871 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2872 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2873 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002874 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002875
2876 // Make sure compute stage is selected
2877 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002878 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2879 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2880 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002881 }
sourav parmarcd5fb182020-07-17 12:58:44 -07002882
2883 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
2884 skip |=
2885 LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
2886 "vkCreateComputePipelines(): flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR");
2887 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002888 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002889 return skip;
2890}
2891
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002892bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002893 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002894 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002895
2896 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002897 const auto &features = physical_device_features;
2898 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002899
John Zulauf71968502017-10-26 13:51:15 -06002900 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2901 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002902 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2903 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2904 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2905 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002906 }
2907
2908 // Anistropy cannot be enabled in sampler unless enabled as a feature
2909 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002910 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2911 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2912 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002913 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002914 }
John Zulauf71968502017-10-26 13:51:15 -06002915
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002916 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2917 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002918 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2919 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2920 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2921 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002922 }
2923 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002924 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2925 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2926 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2927 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002928 }
2929 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002930 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2931 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2932 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2933 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002934 }
2935 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2936 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2937 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2938 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002939 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2940 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2941 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2942 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2943 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2944 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002945 }
2946 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002947 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2948 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2949 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002950 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002951 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002952 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2953 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2954 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002955 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002956 }
2957
2958 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2959 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002960 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2961 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002962 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07002963 if (sampler_reduction != nullptr) {
2964 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
2965 skip |= LogError(
2966 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
2967 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
2968 }
2969 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002970 }
2971
2972 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2973 // valid VkBorderColor value
2974 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2975 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2976 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002977 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2978 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002979 }
2980
2981 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2982 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002983 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002984 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2985 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2986 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002987 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002988 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2989 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2990 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002991 }
John Zulauf275805c2017-10-26 15:34:49 -06002992
2993 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002994 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002995 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2996 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002997 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2998 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2999 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003000 }
3001 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003002
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003003 // Check for valid Lod range
3004 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003005 skip |=
3006 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3007 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003008 }
3009
3010 // Check mipLodBias to device limit
3011 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003012 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3013 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3014 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003015 }
3016
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003017 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003018 if (sampler_conversion != nullptr) {
3019 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3020 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3021 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3022 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003023 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003024 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003025 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3026 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3027 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3028 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3029 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3030 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3031 }
3032 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003033
3034 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3035 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3036 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3037 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3038 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3039 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3040 }
3041 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3042 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3043 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3044 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3045 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3046 }
3047 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3048 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3049 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3050 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3051 pCreateInfo->minLod, pCreateInfo->maxLod);
3052 }
3053 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3054 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3055 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3056 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3057 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3058 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3059 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3060 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3061 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3062 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3063 }
3064 if (pCreateInfo->anisotropyEnable) {
3065 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3066 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3067 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3068 }
3069 if (pCreateInfo->compareEnable) {
3070 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3071 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3072 "pCreateInfo->compareEnable must be VK_FALSE");
3073 }
3074 if (pCreateInfo->unnormalizedCoordinates) {
3075 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3076 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3077 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3078 }
3079 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003080 }
3081
Tony-LunarG7337b312020-04-15 16:40:25 -06003082 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3083 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3084 if (!device_extensions.vk_ext_custom_border_color) {
3085 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3086 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3087 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3088 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003089 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003090 if (!custom_create_info) {
3091 skip |=
3092 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3093 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3094 "struct in pNext chain.\n",
3095 string_VkBorderColor(pCreateInfo->borderColor));
3096 } else {
3097 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3098 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3099 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3100 !FormatIsSampledFloat(custom_create_info->format)))) {
3101 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3102 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3103 "whose type does not match\n",
3104 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3105 ;
3106 }
3107 }
3108 }
3109
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003110 return skip;
3111}
3112
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003113bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3114 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3115 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003116 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003117 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003118
3119 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3120 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3121 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3122 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003123 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3124 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3125 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3126 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3127 ++descriptor_index) {
3128 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003129 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003130 "vkCreateDescriptorSetLayout: required parameter "
3131 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3132 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003133 }
3134 }
3135 }
3136
3137 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3138 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3139 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003140 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3141 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3142 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3143 "values.",
3144 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003145 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003146
3147 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3148 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3149 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3150 skip |=
3151 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3152 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3153 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3154 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3155 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3156 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003157 }
3158 }
3159 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003160 return skip;
3161}
3162
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003163bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3164 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003165 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003166 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3167 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3168 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003169 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3170 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003171}
3172
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003173bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3174 const VkWriteDescriptorSet *pDescriptorWrites,
3175 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003176 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003177
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003178 if (pDescriptorWrites != NULL) {
3179 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3180 // descriptorCount must be greater than 0
3181 if (pDescriptorWrites[i].descriptorCount == 0) {
3182 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003183 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3184 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003185 }
3186
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003187 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3188 if (validateDstSet) {
3189 // dstSet must be a valid VkDescriptorSet handle
3190 skip |= validate_required_handle(vkCallingFunction,
3191 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3192 pDescriptorWrites[i].dstSet);
3193 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003194
3195 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3196 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3197 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3198 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3199 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3200 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3201 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003202 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3203 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003204 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003205 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3206 "%s(): if pDescriptorWrites[%d].descriptorType is "
3207 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3208 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3209 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3210 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003211 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3212 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003213 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3214 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003215 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3216 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003217 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003218 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3219 ParameterName::IndexVector{i, descriptor_index}),
3220 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003221 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003222 }
3223 }
3224 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3225 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3226 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3227 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3228 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3229 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3230 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003231 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003232 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003233 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3234 "%s(): if pDescriptorWrites[%d].descriptorType is "
3235 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3236 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3237 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3238 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003239 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003240 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003241 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003242 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003243 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3244 ++descriptor_index) {
3245 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3246 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3247 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003248 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3249 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003250 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003251 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3252 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003253 }
3254 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003255 }
3256 }
3257 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3258 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003259 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003260 }
3261
3262 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3263 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003264 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003265 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3266 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003267 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003268 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003269 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3270 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3271 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003272 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003273 }
3274 }
3275 }
3276 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3277 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003278 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003279 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3280 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003281 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003282 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003283 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3284 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3285 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003286 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003287 }
3288 }
3289 }
3290 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003291 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3292 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003293 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003294 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003295 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3296 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3297 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3298 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3299 "accelerationStructureCount %d member equals descriptorCount %d.",
3300 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3301 pDescriptorWrites[i].descriptorCount);
3302 }
3303 // further checks only if we have right structtype
3304 if (pnext_struct) {
3305 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3306 skip |= LogError(
3307 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3308 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3309 ".",
3310 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003311 }
sourav parmarbcee7512020-12-28 14:34:49 -08003312 if (pnext_struct->accelerationStructureCount == 0) {
3313 skip |= LogError(device,
3314 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
3315 "%s(): accelerationStructureCount must be greater than 0 .");
3316 }
3317 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003318 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003319 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3320 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3321 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3322 skip |= LogError(device,
3323 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3324 "%s(): If the nullDescriptor feature is not enabled, each member of "
3325 "pAccelerationStructures must not be VK_NULL_HANDLE.");
sourav parmarcd5fb182020-07-17 12:58:44 -07003326 }
3327 }
3328 }
sourav parmarbcee7512020-12-28 14:34:49 -08003329 }
3330 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003331 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003332 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3333 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3334 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3335 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3336 "accelerationStructureCount %d member equals descriptorCount %d.",
3337 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3338 pDescriptorWrites[i].descriptorCount);
3339 }
3340 // further checks only if we have right structtype
3341 if (pnext_struct) {
3342 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3343 skip |= LogError(
3344 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3345 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3346 ".",
3347 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003348 }
sourav parmarbcee7512020-12-28 14:34:49 -08003349 if (pnext_struct->accelerationStructureCount == 0) {
3350 skip |= LogError(device,
3351 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
3352 "%s(): accelerationStructureCount must be greater than 0 .");
3353 }
3354 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003355 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003356 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3357 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3358 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3359 skip |= LogError(device,
3360 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3361 "%s(): If the nullDescriptor feature is not enabled, each member of "
3362 "pAccelerationStructures must not be VK_NULL_HANDLE.");
sourav parmarcd5fb182020-07-17 12:58:44 -07003363 }
3364 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003365 }
3366 }
3367 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003368 }
3369 }
3370 return skip;
3371}
3372
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003373bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3374 const VkWriteDescriptorSet *pDescriptorWrites,
3375 uint32_t descriptorCopyCount,
3376 const VkCopyDescriptorSet *pDescriptorCopies) const {
3377 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3378}
3379
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003380bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003381 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003382 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003383 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3384}
3385
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003386bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3387 const VkAllocationCallbacks *pAllocator,
3388 VkRenderPass *pRenderPass) const {
3389 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3390}
3391
Mike Schuchardt2df08912020-12-15 16:28:09 -08003392bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003393 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003394 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003395 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3396}
3397
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003398bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3399 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003400 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003401 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003402
3403 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3404 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3405 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003406 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3407 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003408 return skip;
3409}
3410
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003411bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003412 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003413 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003414
3415 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3416 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003417 bool cb_is_secondary;
3418 {
3419 auto lock = cb_read_lock();
3420 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3421 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003422
Tony-LunarG3c287f62020-12-17 12:39:49 -07003423 if (cb_is_secondary) {
3424 // Implicit VUs
3425 // validate only sType here; pointer has to be validated in core_validation
3426 const bool k_not_required = false;
3427 const char *k_no_vuid = nullptr;
3428 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3429 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003430 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3431 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003432
Tony-LunarG3c287f62020-12-17 12:39:49 -07003433 if (info) {
3434 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003435 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003436 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003437 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3438 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3439 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3440 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003441
Tony-LunarG3c287f62020-12-17 12:39:49 -07003442 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003443
Tony-LunarG3c287f62020-12-17 12:39:49 -07003444 // Explicit VUs
3445 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003446 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003447 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3448 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3449 cmd_name);
3450 }
3451
3452 if (physical_device_features.inheritedQueries) {
3453 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003454 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3455 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3456 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003457 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003458 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003459 }
3460
3461 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003462 skip |=
3463 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
3464 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
3465 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
3466 } else { // !pipelineStatisticsQuery
3467 skip |=
3468 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
3469 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003470 }
3471
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003472 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003473 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003474 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003475 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3476 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
3477 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003478 commandBuffer,
3479 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07003480 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3481 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3482 }
Petr Kraus139757b2019-08-15 17:19:33 +02003483 }
3484 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003485 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003486 return skip;
3487}
3488
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003489bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003490 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003491 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003492
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003493 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003494 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003495 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3496 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3497 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003498 }
3499 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003500 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3501 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3502 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003503 }
3504 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003505 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003506 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003507 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3508 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3509 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3510 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003511 }
3512 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003513
3514 if (pViewports) {
3515 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3516 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003517 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003518 skip |= manual_PreCallValidateViewport(
3519 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003520 }
3521 }
3522
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003523 return skip;
3524}
3525
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003526bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003527 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003528 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003529
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003530 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003531 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003532 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3533 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3534 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003535 }
3536 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003537 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3538 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3539 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003540 }
3541 } else { // multiViewport enabled
3542 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003543 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003544 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3545 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3546 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3547 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003548 }
3549 }
3550
Petr Kraus6260f0a2018-02-27 21:15:55 +01003551 if (pScissors) {
3552 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3553 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003554
Petr Kraus6260f0a2018-02-27 21:15:55 +01003555 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003556 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3557 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3558 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003559 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003560
Petr Kraus6260f0a2018-02-27 21:15:55 +01003561 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003562 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3563 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3564 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003565 }
3566
3567 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3568 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003569 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3570 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3571 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3572 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003573 }
3574
3575 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3576 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003577 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3578 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3579 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3580 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003581 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003582 }
3583 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003584
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003585 return skip;
3586}
3587
Jeff Bolz5c801d12019-10-09 10:38:45 -05003588bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003589 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003590
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003591 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003592 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3593 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003594 }
3595
3596 return skip;
3597}
3598
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003599bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003600 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003601 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003602
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003603 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003604 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003605 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
3606 }
3607 if (drawCount > device_limits.maxDrawIndirectCount) {
3608 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003609 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
3610 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003611 }
3612 return skip;
3613}
3614
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003615bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003616 VkDeviceSize offset, uint32_t drawCount,
3617 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003618 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003619 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003620 skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
3621 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
3622 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003623 }
3624 if (drawCount > device_limits.maxDrawIndirectCount) {
3625 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003626 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).",
3627 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003628 }
3629 return skip;
3630}
3631
sfricke-samsungf692b972020-05-02 08:00:45 -07003632bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3633 VkDeviceSize countBufferOffset, bool khr) const {
3634 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003635 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003636 if (offset & 3) {
3637 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003638 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003639 }
3640
3641 if (countBufferOffset & 3) {
3642 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003643 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003644 countBufferOffset);
3645 }
3646 return skip;
3647}
3648
3649bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3650 VkDeviceSize offset, VkBuffer countBuffer,
3651 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3652 uint32_t stride) const {
3653 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3654}
3655
3656bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3657 VkDeviceSize offset, VkBuffer countBuffer,
3658 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3659 uint32_t stride) const {
3660 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3661}
3662
3663bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3664 VkDeviceSize countBufferOffset, bool khr) const {
3665 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003666 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003667 if (offset & 3) {
3668 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003669 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003670 }
3671
3672 if (countBufferOffset & 3) {
3673 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003674 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07003675 countBufferOffset);
3676 }
3677 return skip;
3678}
3679
3680bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3681 VkDeviceSize offset, VkBuffer countBuffer,
3682 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3683 uint32_t stride) const {
3684 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3685}
3686
3687bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3688 VkDeviceSize offset, VkBuffer countBuffer,
3689 VkDeviceSize countBufferOffset,
3690 uint32_t maxDrawCount, uint32_t stride) const {
3691 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3692}
3693
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003694bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3695 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003696 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003697 bool skip = false;
3698 for (uint32_t rect = 0; rect < rectCount; rect++) {
3699 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003700 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3701 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003702 }
sfricke-samsung10867682020-04-25 02:20:39 -07003703 if (pRects[rect].rect.extent.width == 0) {
3704 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3705 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3706 }
3707 if (pRects[rect].rect.extent.height == 0) {
3708 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3709 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3710 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003711 }
3712 return skip;
3713}
3714
Andrew Fobel3abeb992020-01-20 16:33:22 -05003715bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3716 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3717 VkImageFormatProperties2 *pImageFormatProperties,
3718 const char *apiName) const {
3719 bool skip = false;
3720
3721 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003722 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003723 if (image_stencil_struct != nullptr) {
3724 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3725 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3726 // No flags other than the legal attachment bits may be set
3727 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3728 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003729 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3730 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3731 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3732 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3733 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003734 }
3735 }
3736 }
3737 }
3738
3739 return skip;
3740}
3741
3742bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3743 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3744 VkImageFormatProperties2 *pImageFormatProperties) const {
3745 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3746 "vkGetPhysicalDeviceImageFormatProperties2");
3747}
3748
3749bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3750 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3751 VkImageFormatProperties2 *pImageFormatProperties) const {
3752 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3753 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3754}
3755
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03003756bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
3757 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
3758 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
3759 bool skip = false;
3760
3761 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
3762 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
3763 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
3764 }
3765
3766 return skip;
3767}
3768
sfricke-samsung3999ef62020-02-09 17:05:59 -08003769bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3770 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3771 bool skip = false;
3772
3773 if (pRegions != nullptr) {
3774 for (uint32_t i = 0; i < regionCount; i++) {
3775 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003776 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3777 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003778 }
3779 }
3780 }
3781 return skip;
3782}
3783
Jeff Leger178b1e52020-10-05 12:22:23 -04003784bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
3785 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
3786 bool skip = false;
3787
3788 if (pCopyBufferInfo->pRegions != nullptr) {
3789 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
3790 if (pCopyBufferInfo->pRegions[i].size == 0) {
3791 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
3792 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
3793 }
3794 }
3795 }
3796 return skip;
3797}
3798
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003799bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003800 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3801 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003802 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003803
3804 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003805 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3806 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3807 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003808 }
3809
3810 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003811 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3812 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3813 "), must be greater than zero and less than or equal to 65536.",
3814 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003815 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003816 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3817 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3818 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003819 }
3820 return skip;
3821}
3822
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003823bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003824 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003825 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003826
3827 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003828 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3829 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3830 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003831 }
3832
3833 if (size != VK_WHOLE_SIZE) {
3834 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003835 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003836 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3837 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003838 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003839 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3840 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003841 }
3842 }
3843 return skip;
3844}
3845
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003846bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003847 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003848 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003849 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003850
3851 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003852 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3853 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3854 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3855 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003856 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3857 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3858 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003859 }
3860
3861 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3862 // queueFamilyIndexCount uint32_t values
3863 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003864 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3865 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3866 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3867 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003868 }
3869 }
3870
Dave Houlton413a6782018-05-22 13:01:54 -06003871 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003872 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003873 }
3874
3875 return skip;
3876}
3877
Jeff Bolz5c801d12019-10-09 10:38:45 -05003878bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003879 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003880
3881 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003882 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06003883 if (present_regions) {
3884 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003885 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003886 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3887 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07003888 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003889 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3890 "extension swapchainCount is %i. These values must be equal.",
3891 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003892 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003893 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003894 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3895 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003896 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3897 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3898 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003899 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003900 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003901 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003902 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003903 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003904 }
3905 }
3906
3907 return skip;
3908}
3909
sfricke-samsung5c1b7392020-12-13 22:17:15 -08003910bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
3911 const VkDisplayModeCreateInfoKHR *pCreateInfo,
3912 const VkAllocationCallbacks *pAllocator,
3913 VkDisplayModeKHR *pMode) const {
3914 bool skip = false;
3915
3916 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
3917 if (display_mode_parameters.visibleRegion.width == 0) {
3918 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
3919 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
3920 }
3921 if (display_mode_parameters.visibleRegion.height == 0) {
3922 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
3923 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
3924 }
3925 if (display_mode_parameters.refreshRate == 0) {
3926 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
3927 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
3928 }
3929
3930 return skip;
3931}
3932
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003933#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003934bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3935 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3936 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003937 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003938 bool skip = false;
3939
3940 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003941 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3942 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003943 }
3944
3945 return skip;
3946}
3947#endif // VK_USE_PLATFORM_WIN32_KHR
3948
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003949bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003950 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003951 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003952 bool skip = false;
3953
3954 if (pCreateInfo) {
3955 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003956 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3957 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003958 }
3959
3960 if (pCreateInfo->pPoolSizes) {
3961 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3962 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003963 skip |= LogError(
3964 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003965 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003966 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003967 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3968 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003969 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3970 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3971 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3972 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3973 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003974 }
Petr Krausc8655be2017-09-27 18:56:51 +02003975 }
3976 }
3977 }
3978
3979 return skip;
3980}
3981
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003982bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003983 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003984 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003985
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003986 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003987 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003988 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3989 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3990 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003991 }
3992
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003993 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003994 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003995 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3996 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3997 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003998 }
3999
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004000 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004001 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004002 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4003 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4004 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004005 }
4006
4007 return skip;
4008}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004009
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004010bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004011 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004012 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004013
4014 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004015 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
4016 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07004017 }
4018 return skip;
4019}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004020
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004021bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4022 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004023 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004024 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004025
4026 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004027 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004028 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004029 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4030 "vkCmdDispatch(): baseGroupX (%" PRIu32
4031 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4032 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004033 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004034 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4035 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4036 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4037 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004038 }
4039
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004040 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004041 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004042 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4043 "vkCmdDispatch(): baseGroupY (%" PRIu32
4044 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4045 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004046 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004047 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4048 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4049 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4050 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004051 }
4052
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004053 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004054 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004055 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4056 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4057 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4058 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004059 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004060 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4061 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4062 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4063 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004064 }
4065
4066 return skip;
4067}
4068
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004069bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4070 VkPipelineBindPoint pipelineBindPoint,
4071 VkPipelineLayout layout, uint32_t set,
4072 uint32_t descriptorWriteCount,
4073 const VkWriteDescriptorSet *pDescriptorWrites) const {
4074 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4075}
4076
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004077bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4078 uint32_t firstExclusiveScissor,
4079 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004080 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004081 bool skip = false;
4082
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004083 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004084 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004085 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004086 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4087 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4088 ") is not 0.",
4089 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004090 }
4091 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004092 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004093 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4094 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4095 ") is not 1.",
4096 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004097 }
4098 } else { // multiViewport enabled
4099 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004100 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004101 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4102 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4103 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4104 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004105 }
4106 }
4107
Jeff Bolz3e71f782018-08-29 23:15:45 -05004108 if (pExclusiveScissors) {
4109 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4110 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4111
4112 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004113 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4114 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4115 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004116 }
4117
4118 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004119 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4120 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4121 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004122 }
4123
4124 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4125 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004126 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4127 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4128 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4129 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004130 }
4131
4132 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4133 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004134 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4135 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4136 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4137 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004138 }
4139 }
4140 }
4141
4142 return skip;
4143}
4144
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004145bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4146 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004147 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004148 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004149 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4150 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4151 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4152 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4153 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4154 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004155 }
4156
4157 return skip;
4158}
4159
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004160bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4161 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004162 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004163 bool skip = false;
4164
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004165 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004166 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004167 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004168 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4169 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4170 ") is not 0.",
4171 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004172 }
4173 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004174 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004175 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4176 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4177 ") is not 1.",
4178 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004179 }
4180 }
4181
Jeff Bolz9af91c52018-09-01 21:53:57 -05004182 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004183 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004184 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4185 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4186 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4187 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004188 }
4189
4190 return skip;
4191}
4192
Jeff Bolz5c801d12019-10-09 10:38:45 -05004193bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4194 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4195 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004196 bool skip = false;
4197
Dave Houlton142c4cb2018-10-17 15:04:41 -06004198 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004199 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4200 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4201 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004202 }
4203
4204 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004205 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004206 }
4207
4208 return skip;
4209}
4210
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004211bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004212 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004213 bool skip = false;
4214
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004215 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004216 skip |= LogError(
4217 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004218 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4219 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004220 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004221 }
4222
4223 return skip;
4224}
4225
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004226bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4227 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004228 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004229 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004230 static const int condition_multiples = 0b0011;
4231 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004232 skip |= LogError(
4233 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004234 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004235 }
Lockee1c22882019-06-10 16:02:54 -06004236 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004237 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4238 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4239 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4240 stride);
Lockee1c22882019-06-10 16:02:54 -06004241 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004242 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004243 skip |= LogError(
4244 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4245 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004246 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004247 if (drawCount > device_limits.maxDrawIndirectCount) {
4248 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004249 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4250 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004251 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004252 return skip;
4253}
4254
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004255bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4256 VkDeviceSize offset, VkBuffer countBuffer,
4257 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004258 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004259 bool skip = false;
4260
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004261 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004262 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4263 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4264 "), is not a multiple of 4.",
4265 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004266 }
4267
4268 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004269 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4270 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4271 "), is not a multiple of 4.",
4272 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004273 }
4274
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004275 return skip;
4276}
4277
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004278bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004279 const VkAllocationCallbacks *pAllocator,
4280 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004281 bool skip = false;
4282
4283 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4284 if (pCreateInfo != nullptr) {
4285 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4286 // VkQueryPipelineStatisticFlagBits values
4287 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4288 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004289 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4290 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4291 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4292 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004293 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004294 if (pCreateInfo->queryCount == 0) {
4295 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4296 "vkCreateQueryPool(): queryCount must be greater than zero.");
4297 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004298 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004299 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004300}
4301
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004302bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4303 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004304 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004305 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4306 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004307}
4308
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004309void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004310 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4311 VkResult result) {
4312 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004313 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004314}
4315
Mike Schuchardt2df08912020-12-15 16:28:09 -08004316void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004317 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4318 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004319 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004320 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004321 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004322}
4323
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004324void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4325 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004326 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004327 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004328 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004329}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004330
Tony-LunarG3c287f62020-12-17 12:39:49 -07004331void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004332 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004333 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
4334 auto lock = cb_write_lock();
4335 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004336 secondary_cb_map.insert({pCommandBuffers[cb_index], pAllocateInfo->commandPool});
Tony-LunarG3c287f62020-12-17 12:39:49 -07004337 }
4338 }
4339}
4340
4341void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004342 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004343 auto lock = cb_write_lock();
4344 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
4345 secondary_cb_map.erase(pCommandBuffers[cb_index]);
4346 }
4347}
4348
4349void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004350 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004351 auto lock = cb_write_lock();
4352 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
4353 if (item->second == commandPool) {
4354 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004355 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004356 ++item;
4357 }
4358 }
4359}
4360
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004361bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004362 const VkAllocationCallbacks *pAllocator,
4363 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004364 bool skip = false;
4365
4366 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004367 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004368 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004369 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4370 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004371 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004372
4373 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004374 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004375 if (flags_info) {
4376 flags = flags_info->flags;
4377 }
4378
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004379 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004380 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08004381 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004382 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4383 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08004384 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004385 }
4386
4387#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004388 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004389#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004390 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4391 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004392#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004393 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004394#endif
4395
4396 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004397 skip |= LogError(
4398 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004399 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4400 }
4401 if (
4402#ifdef VK_USE_PLATFORM_WIN32_KHR
4403 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4404#endif
4405 (import_memory_fd && import_memory_fd->handleType) ||
4406#ifdef VK_USE_PLATFORM_ANDROID_KHR
4407 (import_memory_ahb && import_memory_ahb->buffer) ||
4408#endif
4409 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004410 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4411 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004412 }
4413 }
4414
4415 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004416 VkBool32 capture_replay = false;
4417 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004418 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004419 if (vulkan_12_features) {
4420 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4421 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4422 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004423 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004424 if (bda_features) {
4425 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4426 buffer_device_address = bda_features->bufferDeviceAddress;
4427 }
4428 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004429 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004430 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004431 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004432 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004433 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004434 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004435 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004436 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004437 }
4438 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004439 }
4440 return skip;
4441}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004442
Jason Macnak192fa0e2019-07-26 15:07:16 -07004443bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004444 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004445 bool skip = false;
4446
4447 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4448 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4449 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004450 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004451 } else {
4452 uint32_t vertex_component_size = 0;
4453 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4454 vertex_component_size = 4;
4455 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4456 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4457 vertex_component_size = 2;
4458 }
4459 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004460 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004461 }
4462 }
4463
4464 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4465 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004466 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004467 } else {
4468 uint32_t index_element_size = 0;
4469 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4470 index_element_size = 4;
4471 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4472 index_element_size = 2;
4473 }
4474 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004475 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004476 }
4477 }
4478 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4479 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004480 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004481 }
4482 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004483 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004484 }
4485 }
4486
4487 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004488 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004489 }
4490
4491 return skip;
4492}
4493
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004494bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4495 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004496 bool skip = false;
4497
4498 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004499 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004500 }
4501 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004502 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004503 }
4504
4505 return skip;
4506}
4507
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004508bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4509 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004510 bool skip = false;
4511 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004512 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004513 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004514 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004515 }
4516 return skip;
4517}
4518
4519bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004520 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004521 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004522 bool skip = false;
4523 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004524 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4525 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4526 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004527 }
4528 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004529 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4530 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4531 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004532 }
4533 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4534 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004535 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4536 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4537 "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 -07004538 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004539 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004540 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004541 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4542 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004543 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4544 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004545 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004546 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004547 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4548 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4549 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004550 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004551 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004552 uint64_t total_triangle_count = 0;
4553 for (uint32_t i = 0; i < info.geometryCount; i++) {
4554 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004555
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004556 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004557
Jason Macnak5c954952019-07-09 15:46:12 -07004558 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4559 continue;
4560 }
4561 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4562 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004563 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004564 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4565 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4566 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004567 }
4568 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004569 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4570 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4571 for (uint32_t i = 1; i < info.geometryCount; i++) {
4572 const VkGeometryNV &geometry = info.pGeometries[i];
4573 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004574 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004575 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4576 "info.pGeometries[0].geometryType.",
4577 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004578 }
4579 }
4580 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004581 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4582 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4583 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4584 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4585 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4586 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4587 }
4588 }
4589 skip |=
4590 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004591 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004592 return skip;
4593}
4594
Ricardo Garciaa4935972019-02-21 17:43:18 +01004595bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4596 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004597 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004598 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004599 if (pCreateInfo) {
4600 if ((pCreateInfo->compactedSize != 0) &&
4601 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004602 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4603 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4604 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4605 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004606 }
Jason Macnak5c954952019-07-09 15:46:12 -07004607
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004608 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004609 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004610 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004611 return skip;
4612}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004613
Jeff Bolz5c801d12019-10-09 10:38:45 -05004614bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4615 const VkAccelerationStructureInfoNV *pInfo,
4616 VkBuffer instanceData, VkDeviceSize instanceOffset,
4617 VkBool32 update, VkAccelerationStructureNV dst,
4618 VkAccelerationStructureNV src, VkBuffer scratch,
4619 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004620 bool skip = false;
4621
4622 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004623 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004624 }
4625
4626 return skip;
4627}
4628
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004629bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4630 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4631 VkAccelerationStructureKHR *pAccelerationStructure) const {
4632 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07004633 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004634 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07004635 if (!acceleration_structure_features ||
4636 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
4637 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
4638 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
4639 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004640 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004641 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
4642 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004643 (acceleration_structure_features &&
4644 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07004645 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07004646 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
4647 "vkCreateAccelerationStructureKHR(): If createFlags includes "
4648 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
4649 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07004650 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004651 if (pCreateInfo->deviceAddress &&
4652 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
4653 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
4654 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
4655 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
4656 }
4657 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
4658 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
4659 "vkCreateAccelerationStructureKHR(): offset must be a multiple of 256 bytes", pCreateInfo->offset);
4660 }
sourav parmar83c31b12020-05-06 12:30:54 -07004661 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004662 return skip;
4663}
4664
Jason Macnak5c954952019-07-09 15:46:12 -07004665bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4666 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004667 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004668 bool skip = false;
4669 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004670 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4671 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004672 }
4673 return skip;
4674}
4675
sourav parmarcd5fb182020-07-17 12:58:44 -07004676bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
4677 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
4678 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
4679 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07004680 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004681 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-03432",
4682 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07004683 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07004684 }
4685 return skip;
4686}
4687
Peter Chen85366392019-05-14 15:20:11 -04004688bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4689 uint32_t createInfoCount,
4690 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4691 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004692 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004693 bool skip = false;
4694
4695 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004696 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04004697 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004698 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004699 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4700 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4701 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4702 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004703 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004704
4705 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004706 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07004707 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4708 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4709 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4710 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4711 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4712 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4713 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4714 }
4715 }
4716
sourav parmarf4a78252020-04-10 13:04:21 -07004717 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4718 skip |=
4719 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4720 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4721 }
4722 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4723 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4724 skip |=
4725 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4726 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4727 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4728 }
4729 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4730 if (pCreateInfos[i].basePipelineIndex != -1) {
4731 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4732 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4733 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4734 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4735 "and pCreateInfos->basePipelineIndex is not -1.");
4736 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004737 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004738 skip |=
4739 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
4740 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
4741 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
4742 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
4743 "that element.");
4744 }
sourav parmarf4a78252020-04-10 13:04:21 -07004745 }
4746 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004747 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004748 skip |=
4749 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4750 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4751 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4752 "commands pCreateInfos parameter.");
4753 }
4754 } else {
4755 if (pCreateInfos[i].basePipelineIndex != -1) {
4756 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4757 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4758 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4759 }
4760 }
4761 }
4762 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4763 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4764 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4765 }
4766 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4767 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4768 "vkCreateRayTracingPipelinesNV: flags must not include "
4769 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4770 }
4771 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4772 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4773 "vkCreateRayTracingPipelinesNV: flags must not include "
4774 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4775 }
4776 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4777 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4778 "vkCreateRayTracingPipelinesNV: flags must not include "
4779 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4780 }
4781 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4782 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4783 "vkCreateRayTracingPipelinesNV: flags must not include "
4784 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4785 }
4786 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4787 skip |= LogError(
4788 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4789 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4790 }
4791 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4792 skip |= LogError(
4793 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4794 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4795 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004796 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
4797 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
4798 "vkCreateRayTracingPipelinesNV: flags must not include "
4799 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
4800 }
4801 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
4802 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
4803 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
4804 }
Peter Chen85366392019-05-14 15:20:11 -04004805 }
4806
4807 return skip;
4808}
4809
sourav parmarcd5fb182020-07-17 12:58:44 -07004810bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
4811 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
4812 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004813 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004814 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07004815 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
4816 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
4817 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07004818 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004819 for (uint32_t i = 0; i < createInfoCount; i++) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004820 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
4821 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4822 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
4823 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
4824 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4825 }
4826 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4827 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
4828 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
4829 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
4830 }
4831 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004832 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004833 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4834 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07004835 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
4836 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
4837 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004838 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4839 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4840 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004841 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004842 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07004843 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4844 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4845 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4846 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07004847 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07004848 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4849 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4850 }
4851 }
sourav parmarf4a78252020-04-10 13:04:21 -07004852 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004853 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4854 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07004855 }
4856 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004857 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07004858 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07004859 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
4860 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004861 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004862 }
4863 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
4864 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
4865 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07004866 }
4867 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4868 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4869 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4870 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4871 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4872 skip |= LogError(
4873 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07004874 "vkCreateRayTracingPipelinesKHR: If flags includes "
4875 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07004876 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4877 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4878 "must not be VK_SHADER_UNUSED_KHR");
4879 }
4880 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4881 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4882 skip |= LogError(
4883 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07004884 "vkCreateRayTracingPipelinesKHR: If flags includes "
4885 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07004886 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4887 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4888 "element must not be VK_SHADER_UNUSED_KHR");
4889 }
4890 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004891 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
4892 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
4893 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
4894 skip |= LogError(
4895 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
4896 "vkCreateRayTracingPipelinesKHR: If "
4897 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
4898 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
4899 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
4900 }
4901 }
sourav parmarf4a78252020-04-10 13:04:21 -07004902 }
4903 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4904 if (pCreateInfos[i].basePipelineIndex != -1) {
4905 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4906 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07004907 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07004908 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4909 "and pCreateInfos->basePipelineIndex is not -1.");
4910 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004911 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004912 skip |=
4913 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
4914 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
4915 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
4916 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
4917 "element.");
4918 }
sourav parmarf4a78252020-04-10 13:04:21 -07004919 }
4920 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004921 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004922 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07004923 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07004924 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4925 "commands pCreateInfos parameter %d.",
4926 pCreateInfos[i].basePipelineIndex, createInfoCount);
4927 }
4928 } else {
4929 if (pCreateInfos[i].basePipelineIndex != -1) {
4930 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07004931 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07004932 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4933 }
4934 }
4935 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004936 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
4937 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
4938 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
4939 "vkCreateRayTracingPipelinesKHR: If flags includes "
4940 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
4941 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004942 }
4943 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
4944 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
4945 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
4946 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
4947 "pLibraryInfo and pLibraryInterface must be NULL.");
4948 }
4949 if (pCreateInfos[i].pLibraryInfo) {
4950 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
4951 if (pCreateInfos[i].stageCount == 0) {
4952 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
4953 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
4954 "stageCount must not be 0.");
4955 }
4956 if (pCreateInfos[i].groupCount == 0) {
4957 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
4958 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
4959 "groupCount must not be 0.");
4960 }
4961 } else {
4962 if (pCreateInfos[i].pLibraryInterface == NULL) {
4963 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
4964 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
4965 "is greater than 0, its "
4966 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07004967 }
4968 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004969 }
4970 if (pCreateInfos[i].pLibraryInterface) {
4971 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
4972 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
4973 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
4974 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
4975 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
4976 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004977 }
4978 if (deferredOperation != VK_NULL_HANDLE) {
4979 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
4980 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
4981 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
4982 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07004983 }
4984 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004985 }
4986
4987 return skip;
4988}
4989
Mike Schuchardt21638df2019-03-16 10:52:02 -07004990#ifdef VK_USE_PLATFORM_WIN32_KHR
4991bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4992 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004993 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004994 bool skip = false;
4995 if (!device_extensions.vk_khr_swapchain)
4996 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4997 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4998 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4999 if (!device_extensions.vk_khr_surface)
5000 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
5001 if (!device_extensions.vk_khr_get_physical_device_properties_2)
5002 skip |=
5003 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
5004 if (!device_extensions.vk_ext_full_screen_exclusive)
5005 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
5006 skip |= validate_struct_type(
5007 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
5008 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
5009 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
5010 if (pSurfaceInfo != NULL) {
5011 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
5012 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
5013 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
5014
5015 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
5016 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
5017 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5018 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005019 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5020 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005021
5022 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5023 }
5024 return skip;
5025}
5026#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005027
5028bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5029 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005030 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005031 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5032 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005033 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005034 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5035 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5036 }
5037 return skip;
5038}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005039
5040bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005041 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005042 bool skip = false;
5043
5044 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005045 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
5046 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005047 }
5048
5049 return skip;
5050}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005051
5052bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005053 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005054 bool skip = false;
5055
5056 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005057 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5058 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005059 }
5060
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005061 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005062 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005063 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5064 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005065 }
5066
5067 return skip;
5068}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005069
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005070bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5071 uint32_t bindingCount, const VkBuffer *pBuffers,
5072 const VkDeviceSize *pOffsets) const {
5073 bool skip = false;
5074 if (firstBinding > device_limits.maxVertexInputBindings) {
5075 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5076 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
5077 device_limits.maxVertexInputBindings);
5078 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5079 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
5080 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5081 "maxVertexInputBindings (%u)",
5082 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5083 }
5084
Jeff Bolz165818a2020-05-08 11:19:03 -05005085 for (uint32_t i = 0; i < bindingCount; ++i) {
5086 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005087 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005088 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5089 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5090 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5091 } else {
5092 if (pOffsets[i] != 0) {
5093 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5094 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5095 }
5096 }
5097 }
5098 }
5099
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005100 return skip;
5101}
5102
Mark Lobodzinski84988402019-09-11 15:27:30 -06005103bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005104 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005105 bool skip = false;
5106 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005107 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5108 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005109 }
5110 return skip;
5111}
5112
5113bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005114 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005115 bool skip = false;
5116 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005117 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5118 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005119 }
5120 return skip;
5121}
Petr Kraus3d720392019-11-13 02:52:39 +01005122
5123bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5124 VkSemaphore semaphore, VkFence fence,
5125 uint32_t *pImageIndex) const {
5126 bool skip = false;
5127
5128 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005129 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5130 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005131 }
5132
5133 return skip;
5134}
5135
5136bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5137 uint32_t *pImageIndex) const {
5138 bool skip = false;
5139
5140 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005141 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5142 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005143 }
5144
5145 return skip;
5146}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005147
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005148bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5149 uint32_t firstBinding, uint32_t bindingCount,
5150 const VkBuffer *pBuffers,
5151 const VkDeviceSize *pOffsets,
5152 const VkDeviceSize *pSizes) const {
5153 bool skip = false;
5154
5155 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5156 for (uint32_t i = 0; i < bindingCount; ++i) {
5157 if (pOffsets[i] & 3) {
5158 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5159 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5160 }
5161 }
5162
5163 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5164 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5165 "%s: The firstBinding(%" PRIu32
5166 ") index is greater than or equal to "
5167 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5168 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5169 }
5170
5171 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5172 skip |=
5173 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5174 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5175 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5176 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5177 }
5178
5179 for (uint32_t i = 0; i < bindingCount; ++i) {
5180 // pSizes is optional and may be nullptr.
5181 if (pSizes != nullptr) {
5182 if (pSizes[i] != VK_WHOLE_SIZE &&
5183 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5184 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5185 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5186 ") is not VK_WHOLE_SIZE and is greater than "
5187 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5188 cmd_name, i, pSizes[i]);
5189 }
5190 }
5191 }
5192
5193 return skip;
5194}
5195
5196bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5197 uint32_t firstCounterBuffer,
5198 uint32_t counterBufferCount,
5199 const VkBuffer *pCounterBuffers,
5200 const VkDeviceSize *pCounterBufferOffsets) const {
5201 bool skip = false;
5202
5203 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5204 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5205 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5206 "%s: The firstCounterBuffer(%" PRIu32
5207 ") index is greater than or equal to "
5208 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5209 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5210 }
5211
5212 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5213 skip |=
5214 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5215 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5216 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5217 cmd_name, firstCounterBuffer, counterBufferCount,
5218 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5219 }
5220
5221 return skip;
5222}
5223
5224bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5225 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5226 const VkBuffer *pCounterBuffers,
5227 const VkDeviceSize *pCounterBufferOffsets) const {
5228 bool skip = false;
5229
5230 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5231 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5232 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5233 "%s: The firstCounterBuffer(%" PRIu32
5234 ") index is greater than or equal to "
5235 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5236 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5237 }
5238
5239 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5240 skip |=
5241 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5242 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5243 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5244 cmd_name, firstCounterBuffer, counterBufferCount,
5245 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5246 }
5247
5248 return skip;
5249}
5250
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005251bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5252 uint32_t firstInstance, VkBuffer counterBuffer,
5253 VkDeviceSize counterBufferOffset,
5254 uint32_t counterOffset, uint32_t vertexStride) const {
5255 bool skip = false;
5256
5257 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005258 skip |= LogError(
5259 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005260 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5261 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5262 }
5263
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005264 if ((counterOffset % 4) != 0) {
5265 // TODO - Update when header are updated
5266 skip |= LogError(commandBuffer, "UNASSIGNED-vkCmdDrawIndirectByteCountEXT-offset",
5267 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu64 ") must be a multiple of 4.", counterOffset);
5268 }
5269
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005270 return skip;
5271}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005272
5273bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5274 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5275 const VkAllocationCallbacks *pAllocator,
5276 VkSamplerYcbcrConversion *pYcbcrConversion,
5277 const char *apiName) const {
5278 bool skip = false;
5279
5280 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005281 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005282 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005283 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005284 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5285 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005286 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005287 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005288 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005289
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005290#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005291 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005292 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005293#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005294 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005295#endif
5296
sfricke-samsung1a72f942020-07-25 12:09:18 -07005297 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005298
5299 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005300 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005301 const VkComponentMapping components = pCreateInfo->components;
5302 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5303 if (FormatIsXChromaSubsampled(format) == true) {
5304 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5305 skip |=
5306 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005307 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5308 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005309 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005310 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005311
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005312 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5313 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5314 skip |= LogError(
5315 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5316 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5317 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5318 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5319 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005320
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005321 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5322 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5323 skip |=
5324 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005325 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5326 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005327 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005328 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005329
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005330 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5331 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5332 skip |=
5333 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005334 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5335 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005336 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005337 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005338
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005339 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005340 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5341 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5342 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005343 skip |=
5344 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005345 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5346 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005347 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5348 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005349 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005350 }
5351
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005352 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5353 // Checks same VU multiple ways in order to give a more useful error message
5354 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5355 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5356 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5357 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5358 skip |= LogError(
5359 device, vuid,
5360 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5361 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5362 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5363 string_VkComponentSwizzle(components.b));
5364 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005365
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005366 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5367 // 4 channel format = no issue
5368 // 3 = no [a]
5369 // 2 = no [b,a]
5370 // 1 = no [g,b,a]
5371 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5372 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5373
5374 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5375 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5376 skip |= LogError(device, vuid,
5377 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5378 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5379 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5380 string_VkComponentSwizzle(components.b));
5381 } else if ((channels < 3) &&
5382 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5383 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5384 skip |= LogError(device, vuid,
5385 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5386 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5387 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5388 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5389 string_VkComponentSwizzle(components.b));
5390 } else if ((channels < 2) &&
5391 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5392 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5393 skip |= LogError(device, vuid,
5394 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5395 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5396 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5397 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5398 string_VkComponentSwizzle(components.b));
5399 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005400 }
5401 }
5402
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005403 return skip;
5404}
5405
5406bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5407 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5408 const VkAllocationCallbacks *pAllocator,
5409 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5410 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5411 "vkCreateSamplerYcbcrConversion");
5412}
5413
5414bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5415 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5416 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5417 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5418 "vkCreateSamplerYcbcrConversionKHR");
5419}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005420
5421bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5422 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5423 bool skip = false;
5424 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5425 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5426
5427 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005428 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5429 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5430 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5431 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5432 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005433 }
5434 return skip;
5435}
sourav parmara96ab1a2020-04-25 16:28:23 -07005436
5437bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005438 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005439 bool skip = false;
5440 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5441 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5442 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5443 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005444 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005445 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5446 skip |= LogError(
5447 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
5448 "vkCopyAccelerationStructureToMemoryKHR: The "
5449 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5450 }
5451 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
5452 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
5453 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
5454 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
5455 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
5456 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005457 return skip;
5458}
5459
5460bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5461 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5462 bool skip = false;
5463 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5464 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5465 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5466 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5467 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005468 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
5469 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
5470 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress must be aligned to 256 bytes.",
5471 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07005472 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005473 return skip;
5474}
5475
5476bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5477 const char *api_name) const {
5478 bool skip = false;
5479 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5480 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5481 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5482 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5483 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5484 api_name);
5485 }
5486 return skip;
5487}
5488
5489bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005490 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005491 bool skip = false;
5492 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005493 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005494 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07005495 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07005496 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
5497 "vkCopyAccelerationStructureKHR: The "
5498 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005499 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005500 return skip;
5501}
5502
5503bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5504 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5505 bool skip = false;
5506 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5507 return skip;
5508}
5509
5510bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005511 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005512 bool skip = false;
5513 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005514 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005515 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5516 }
5517 return skip;
5518}
5519
5520bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005521 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005522 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005523 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005524 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005525 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5526 skip |= LogError(
5527 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
5528 "vkCopyMemoryToAccelerationStructureKHR: The "
5529 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005530 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005531 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
5532 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07005533 return skip;
5534}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005535
sourav parmara96ab1a2020-04-25 16:28:23 -07005536bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5537 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5538 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005539 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07005540 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
5541 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
5542 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress must be aligned to 256 bytes.",
5543 pInfo->src.deviceAddress);
5544 }
sourav parmar83c31b12020-05-06 12:30:54 -07005545 return skip;
5546}
5547bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5548 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5549 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5550 bool skip = false;
5551 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5552 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5553 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5554 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5555 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5556 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5557 }
5558 return skip;
5559}
5560bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5561 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5562 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5563 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005564 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005565 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
5566 skip |= LogError(
5567 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
5568 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
5569 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5570 }
sourav parmar83c31b12020-05-06 12:30:54 -07005571 if (dataSize < accelerationStructureCount * stride) {
5572 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5573 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5574 "accelerationStructureCount (%d) *stride(%zu).",
5575 dataSize, accelerationStructureCount, stride);
5576 }
5577 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5578 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5579 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5580 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5581 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5582 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5583 }
5584 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5585 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5586 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5587 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5588 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5589 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5590 stride);
5591 }
5592 }
5593 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5594 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5595 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5596 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5597 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5598 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5599 stride);
5600 }
5601 }
sourav parmar83c31b12020-05-06 12:30:54 -07005602 return skip;
5603}
5604bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5605 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5606 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005607 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005608 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
5609 skip |= LogError(
5610 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
5611 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
5612 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07005613 }
5614 return skip;
5615}
5616
5617bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07005618 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
5619 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
5620 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
5621 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07005622 uint32_t width, uint32_t height, uint32_t depth) const {
5623 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005624 // RayGen
5625 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
5626 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
5627 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07005628 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005629 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5630 0) {
5631 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
5632 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
5633 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5634 }
5635 // Callable
5636 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5637 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
5638 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
5639 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005640 }
5641 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5642 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5643 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005644 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5645 }
5646 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5647 0) {
5648 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
5649 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
5650 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005651 }
5652 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005653 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5654 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
5655 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
5656 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005657 }
5658 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5659 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07005660 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
5661 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07005662 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005663 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5664 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
5665 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
5666 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5667 }
sourav parmar83c31b12020-05-06 12:30:54 -07005668 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005669 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5670 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
5671 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
5672 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07005673 }
5674 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5675 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5676 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005677 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5678 }
5679 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5680 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
5681 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
5682 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5683 }
5684 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
5685 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
5686 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
5687 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
5688 }
5689 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
5690 skip |=
5691 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
5692 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
5693 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07005694 }
5695
sourav parmarcd5fb182020-07-17 12:58:44 -07005696 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
5697 skip |=
5698 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
5699 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
5700 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
5701 }
5702
5703 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
5704 skip |=
5705 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
5706 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
5707 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07005708 }
5709 return skip;
5710}
5711
sourav parmarcd5fb182020-07-17 12:58:44 -07005712bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
5713 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
5714 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
5715 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07005716 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005717 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005718 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
5719 skip |= LogError(
5720 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
5721 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
5722 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005723 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005724 // RayGen
5725 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
5726 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
5727 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07005728 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005729 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5730 0) {
5731 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
5732 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
5733 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5734 }
5735 // Callabe
5736 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5737 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
5738 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
5739 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005740 }
5741 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5742 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07005743 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
5744 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5745 }
5746 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5747 0) {
5748 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
5749 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
5750 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005751 }
5752 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005753 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5754 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
5755 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
5756 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005757 }
5758 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5759 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07005760 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
5761 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07005762 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005763 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5764 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
5765 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
5766 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5767 }
sourav parmar83c31b12020-05-06 12:30:54 -07005768 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005769 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5770 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
5771 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
5772 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005773 }
5774 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5775 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07005776 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
5777 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5778 }
5779 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5780 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
5781 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
5782 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005783 }
5784
sourav parmarcd5fb182020-07-17 12:58:44 -07005785 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
5786 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
5787 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07005788 }
5789 return skip;
5790}
5791bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5792 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5793 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5794 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5795 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5796 uint32_t width, uint32_t height, uint32_t depth) const {
5797 bool skip = false;
5798 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5799 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5800 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5801 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5802 }
5803 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5804 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5805 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5806 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5807 }
5808 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5809 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5810 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5811 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5812 }
5813
5814 // hitShader
5815 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5816 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5817 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5818 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5819 }
5820 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5821 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5822 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5823 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5824 }
5825 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5826 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5827 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5828 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5829 }
5830
5831 // missShader
5832 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5833 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5834 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5835 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5836 }
5837 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5838 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5839 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5840 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5841 }
5842 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5843 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5844 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5845 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5846 }
5847
5848 // raygenShader
5849 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5850 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5851 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07005852 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5853 }
5854 if (width > device_limits.maxComputeWorkGroupCount[0]) {
5855 skip |=
5856 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
5857 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
5858 }
5859 if (height > device_limits.maxComputeWorkGroupCount[1]) {
5860 skip |=
5861 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
5862 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
5863 }
5864 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
5865 skip |=
5866 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
5867 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07005868 }
5869 return skip;
5870}
5871
sourav parmar83c31b12020-05-06 12:30:54 -07005872bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005873 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
5874 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07005875 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005876 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
5877 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005878 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
5879 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005880 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07005881 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5882 }
5883 return skip;
5884}
5885
Piers Daniell39842ee2020-07-10 16:42:33 -06005886bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
5887 const VkViewport *pViewports) const {
5888 bool skip = false;
5889
5890 if (!physical_device_features.multiViewport) {
5891 if (viewportCount != 1) {
5892 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
5893 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5894 ") is not 1.",
5895 viewportCount);
5896 }
5897 } else { // multiViewport enabled
5898 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
5899 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
5900 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
5901 ") must "
5902 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5903 viewportCount, device_limits.maxViewports);
5904 }
5905 }
5906
5907 if (pViewports) {
5908 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
5909 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
5910 const char *fn_name = "vkCmdSetViewportWithCountEXT";
5911 skip |= manual_PreCallValidateViewport(
5912 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
5913 }
5914 }
5915
5916 return skip;
5917}
5918
5919bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
5920 const VkRect2D *pScissors) const {
5921 bool skip = false;
5922
5923 if (!physical_device_features.multiViewport) {
5924 if (scissorCount != 1) {
5925 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
5926 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5927 ") must "
5928 "be 1 when the multiViewport feature is disabled.",
5929 scissorCount);
5930 }
5931 } else { // multiViewport enabled
5932 if (scissorCount == 0) {
5933 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5934 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5935 ") must "
5936 "be great than zero.",
5937 scissorCount);
5938 } else if (scissorCount > device_limits.maxViewports) {
5939 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5940 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5941 ") must "
5942 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5943 scissorCount, device_limits.maxViewports);
5944 }
5945 }
5946
5947 if (pScissors) {
5948 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
5949 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
5950
5951 if (scissor.offset.x < 0) {
5952 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5953 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
5954 scissor.offset.x);
5955 }
5956
5957 if (scissor.offset.y < 0) {
5958 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5959 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
5960 scissor.offset.y);
5961 }
5962
5963 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5964 if (x_sum > INT32_MAX) {
5965 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
5966 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5967 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5968 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
5969 }
5970
5971 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5972 if (y_sum > INT32_MAX) {
5973 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
5974 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5975 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5976 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
5977 }
5978 }
5979 }
5980
5981 return skip;
5982}
5983
5984bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5985 uint32_t bindingCount, const VkBuffer *pBuffers,
5986 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
5987 const VkDeviceSize *pStrides) const {
5988 bool skip = false;
5989 if (firstBinding >= device_limits.maxVertexInputBindings) {
5990 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
5991 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
5992 firstBinding, device_limits.maxVertexInputBindings);
5993 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5994 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
5995 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5996 "maxVertexInputBindings (%u)",
5997 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5998 }
5999
6000 for (uint32_t i = 0; i < bindingCount; ++i) {
6001 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006002 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06006003 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
6004 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
6005 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
6006 } else {
6007 if (pOffsets[i] != 0) {
6008 skip |=
6009 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
6010 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
6011 }
6012 }
6013 }
6014 if (pStrides) {
6015 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
6016 skip |=
6017 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
6018 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%u) must be less than maxVertexInputBindingStride (%u)", i,
6019 pStrides[i], device_limits.maxVertexInputBindingStride);
6020 }
6021 }
6022 }
6023
6024 return skip;
6025}
sourav parmarcd5fb182020-07-17 12:58:44 -07006026
6027bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6028 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6029 bool skip = false;
6030 for (uint32_t i = 0; i < infoCount; ++i) {
6031 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6032 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6033 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6034 }
6035 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6036 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6037 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6038 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6039 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6040 api_name);
6041 }
6042 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6043 skip |=
6044 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6045 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6046 }
6047 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6048 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6049 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6050 }
6051 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6052 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6053 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6054 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6055 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6056 api_name);
6057 }
6058 if (pInfos[i].pGeometries) {
6059 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6060 skip |= validate_ranged_enum(
6061 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6062 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6063 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6064 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006065 skip |= validate_struct_type(
6066 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6067 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6068 &(pInfos[i].pGeometries[j].geometry.triangles),
6069 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6070 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6071 skip |= validate_struct_pnext(
6072 api_name,
6073 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6074 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6075 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6076 skip |=
6077 validate_ranged_enum(api_name,
6078 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6079 ParameterName::IndexVector{i, j}),
6080 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6081 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6082 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6083 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6084 &pInfos[i].pGeometries[j].geometry.triangles,
6085 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6086 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6087 skip |= validate_ranged_enum(
6088 api_name,
6089 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6090 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6091 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6092
6093 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6094 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6095 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6096 }
6097 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6098 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6099 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6100 skip |=
6101 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6102 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6103 api_name);
6104 }
6105 }
6106 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6107 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6108 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6109 &pInfos[i].pGeometries[j].geometry.instances,
6110 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6111 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6112 skip |= validate_struct_type(
6113 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6114 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6115 &(pInfos[i].pGeometries[j].geometry.instances),
6116 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6117 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6118 skip |= validate_struct_pnext(
6119 api_name,
6120 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6121 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6122 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6123
6124 skip |= validate_bool32(api_name,
6125 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6126 ParameterName::IndexVector{i, j}),
6127 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6128 }
6129 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6130 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6131 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6132 &pInfos[i].pGeometries[j].geometry.aabbs,
6133 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6134 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6135 skip |= validate_struct_type(
6136 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6137 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6138 &(pInfos[i].pGeometries[j].geometry.aabbs),
6139 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6140 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6141 skip |= validate_struct_pnext(
6142 api_name,
6143 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6144 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6145 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6146 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6147 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6148 "(%s):stride must be less than or equal to 2^32-1", api_name);
6149 }
6150 }
6151 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6152 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6153 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6154 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6155 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6156 api_name);
6157 }
6158 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6159 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6160 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6161 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6162 "of elements of"
6163 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6164 api_name);
6165 }
6166 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6167 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6168 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6169 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6170 api_name);
6171 }
6172 }
6173 }
6174 }
6175 if (pInfos[i].ppGeometries != NULL) {
6176 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6177 skip |= validate_ranged_enum(
6178 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6179 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6180 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6181 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006182 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6183 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6184 &pInfos[i].ppGeometries[j]->geometry.triangles,
6185 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6186 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6187 skip |= validate_struct_type(
6188 api_name,
6189 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6190 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6191 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6192 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6193 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6194 skip |= validate_struct_pnext(
6195 api_name,
6196 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6197 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6198 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6199 skip |= validate_ranged_enum(api_name,
6200 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6201 ParameterName::IndexVector{i, j}),
6202 "VkFormat", AllVkFormatEnums,
6203 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6204 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6205 skip |= validate_ranged_enum(api_name,
6206 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6207 ParameterName::IndexVector{i, j}),
6208 "VkIndexType", AllVkIndexTypeEnums,
6209 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6210 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6211 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6212 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6213 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6214 }
6215 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6216 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6217 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6218 skip |=
6219 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6220 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6221 api_name);
6222 }
6223 }
6224 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6225 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6226 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6227 &pInfos[i].ppGeometries[j]->geometry.instances,
6228 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6229 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6230 skip |= validate_struct_type(
6231 api_name,
6232 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6233 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6234 &(pInfos[i].ppGeometries[j]->geometry.instances),
6235 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6236 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6237 skip |= validate_struct_pnext(
6238 api_name,
6239 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6240 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6241 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6242 skip |= validate_bool32(api_name,
6243 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6244 ParameterName::IndexVector{i, j}),
6245 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6246 }
6247 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6248 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6249 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6250 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6251 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6252 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6253 skip |= validate_struct_type(
6254 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6255 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6256 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6257 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6258 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6259 skip |= validate_struct_pnext(
6260 api_name,
6261 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6262 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6263 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6264 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6265 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6266 "(%s):stride must be less than or equal to 2^32-1", api_name);
6267 }
6268 }
6269 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6270 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6271 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6272 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6273 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6274 api_name);
6275 }
6276 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6277 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6278 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6279 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6280 "of elements of"
6281 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6282 api_name);
6283 }
6284 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6285 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6286 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6287 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6288 api_name);
6289 }
6290 }
6291 }
6292 }
6293 }
6294 return skip;
6295}
6296bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6297 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6298 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6299 bool skip = false;
6300 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6301 for (uint32_t i = 0; i < infoCount; ++i) {
6302 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6303 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6304 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6305 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6306 "scratchData.deviceAddress member must be a multiple of "
6307 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6308 }
6309 for (uint32_t k = 0; k < infoCount; ++k) {
6310 if (i == k) continue;
6311 bool found = false;
6312 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6313 skip |= LogError(
6314 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6315 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6316 "not be "
6317 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6318 i, k);
6319 found = true;
6320 }
6321 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6322 skip |= LogError(
6323 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
6324 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
6325 "not be "
6326 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6327 i, k);
6328 found = true;
6329 }
6330 if (found) break;
6331 }
6332 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6333 if (pInfos[i].pGeometries) {
6334 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6335 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6336 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6337 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6338 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6339 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6340 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6341 }
6342 } else {
6343 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6344 skip |=
6345 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6346 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6347 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6348 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6349 }
6350 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006351 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006352 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6353 skip |= LogError(
6354 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6355 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6356 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6357 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006358 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6359 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006360 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6361 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6362 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6363 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6364 }
6365 }
6366 } else if (pInfos[i].ppGeometries) {
6367 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6368 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6369 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6370 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6371 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6372 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6373 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6374 }
6375 } else {
6376 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6377 skip |=
6378 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6379 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6380 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6381 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6382 }
6383 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006384 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006385 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6386 skip |= LogError(
6387 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6388 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6389 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6390 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006391 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6392 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006393 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6394 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6395 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6396 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6397 }
6398 }
6399 }
6400 }
6401 }
6402 return skip;
6403}
6404
6405bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
6406 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6407 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
6408 const uint32_t *const *ppMaxPrimitiveCounts) const {
6409 bool skip = false;
6410 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
6411 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006412 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006413 if (!ray_tracing_acceleration_structure_features ||
6414 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
6415 skip |= LogError(
6416 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
6417 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
6418 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
6419 }
6420 for (uint32_t i = 0; i < infoCount; ++i) {
6421 if (pInfos[i].mode == VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR) {
6422 if (pInfos[i].srcAccelerationStructure == VK_NULL_HANDLE) {
6423 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03666",
6424 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, if its mode member is "
6425 "VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, its srcAccelerationStructure member must not be "
6426 "VK_NULL_HANDLE.");
6427 }
6428 }
6429 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6430 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6431 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
6432 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
6433 "scratchData.deviceAddress member must be a multiple of "
6434 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6435 }
6436 for (uint32_t k = 0; k < infoCount; ++k) {
6437 if (i == k) continue;
6438 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6439 skip |=
6440 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
6441 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
6442 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
6443 "any other element [%d) of pInfos.",
6444 i, k);
6445 break;
6446 }
6447 }
6448 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6449 if (pInfos[i].pGeometries) {
6450 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6451 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6452 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6453 skip |= LogError(
6454 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6455 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6456 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6457 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6458 }
6459 } else {
6460 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6461 skip |= LogError(
6462 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6463 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6464 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6465 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6466 }
6467 }
6468 }
6469 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6470 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6471 skip |= LogError(
6472 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6473 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6474 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6475 }
6476 }
6477 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6478 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
6479 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6480 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6481 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6482 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6483 }
6484 }
6485 } else if (pInfos[i].ppGeometries) {
6486 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6487 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6488 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6489 skip |= LogError(
6490 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6491 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6492 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6493 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6494 }
6495 } else {
6496 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6497 skip |= LogError(
6498 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6499 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6500 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6501 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6502 }
6503 }
6504 }
6505 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6506 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6507 skip |= LogError(
6508 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6509 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6510 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6511 }
6512 }
6513 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6514 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
6515 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6516 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6517 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6518 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6519 }
6520 }
6521 }
6522 }
6523 }
6524 return skip;
6525}
6526
6527bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
6528 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
6529 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6530 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6531 bool skip = false;
6532 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
6533 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006534 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006535 if (!ray_tracing_acceleration_structure_features ||
6536 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6537 skip |=
6538 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
6539 "vkBuildAccelerationStructuresKHR: The "
6540 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
6541 }
6542 for (uint32_t i = 0; i < infoCount; ++i) {
6543 for (uint32_t j = 0; j < infoCount; ++j) {
6544 if (i == j) continue;
6545 bool found = false;
6546 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6547 skip |= LogError(
6548 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6549 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
6550 "not be "
6551 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6552 i, j);
6553 found = true;
6554 }
6555 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6556 skip |= LogError(
6557 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
6558 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
6559 "not be "
6560 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6561 i, j);
6562 found = true;
6563 }
6564 if (found) break;
6565 }
6566 }
6567 return skip;
6568}
6569
6570bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
6571 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
6572 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
6573 bool skip = false;
6574 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
6575 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006576 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
6577 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006578 if (!(ray_tracing_pipeline_features || ray_query_features) ||
6579 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
6580 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
6581 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
6582 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
6583 }
6584 return skip;
6585}