blob: d31e6fc76c54796d9cd3a14cee06346477028e45 [file] [log] [blame]
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07001/* Copyright (c) 2015-2021 The Khronos Group Inc.
2 * Copyright (c) 2015-2021 Valve Corporation
3 * Copyright (c) 2015-2021 LunarG, Inc.
4 * Copyright (C) 2015-2021 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070028static const int kMaxParamCheckerStringLength = 256;
Mark Lobodzinskid4950072017-08-01 13:02:20 -060029
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinski21b91fe2020-12-03 15:44:24 -070036read_lock_guard_t StatelessValidation::read_lock() { return read_lock_guard_t(validation_object_mutex, std::defer_lock); }
37write_lock_guard_t StatelessValidation::write_lock() { return write_lock_guard_t(validation_object_mutex, std::defer_lock); }
38
Jeremy Gebbencbf22862021-03-03 12:01:22 -070039static layer_data::unordered_map<VkCommandBuffer, VkCommandPool> secondary_cb_map{};
Tony-LunarG3c287f62020-12-17 12:39:49 -070040static ReadWriteLock secondary_cb_map_mutex;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -070041static read_lock_guard_t cb_read_lock() { return read_lock_guard_t(secondary_cb_map_mutex); }
42static write_lock_guard_t cb_write_lock() { return write_lock_guard_t(secondary_cb_map_mutex); }
Tony-LunarG3c287f62020-12-17 12:39:49 -070043
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070044bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050045 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060046 bool skip = false;
47
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070048 VkStringErrorFlags result = vk_string_validate(kMaxParamCheckerStringLength, validateString);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060049
50 if (result == VK_STRING_ERROR_NONE) {
51 return skip;
52 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070053 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070054 kMaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060055 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070056 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
57 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060058 }
59 return skip;
60}
61
Jeff Bolz46c0ea02019-10-09 13:06:29 -050062bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060063 bool skip = false;
64 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
65 if (api_version_nopatch != effective_api_version) {
sfricke-samsung6aec21b2020-11-01 07:49:43 -080066 if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) {
67 skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070068 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
69 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
70 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060071 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070072 skip |= LogWarning(instance, kVUIDUndefined,
73 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
74 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
75 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060076 }
77 }
78 return skip;
79}
80
Jeff Bolz46c0ea02019-10-09 13:06:29 -050081bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060082 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060083 // Create and use a local instance extension object, as an actual instance has not been created yet
84 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
85 InstanceExtensions local_instance_extensions;
86 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
87
John Zulauf620755c2018-04-16 11:00:43 -060088 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060089 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
90 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060091 }
92
93 return skip;
94}
95
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060096bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const {
Mike Schuchardtc57de4a2021-07-20 17:26:32 -070097 if (instance_extensions.vk_khr_get_physical_device_properties2) {
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060098 // Struct is legal IF it's supported
99 const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device);
100 if (dev_exts_enumerated == device_extensions_enumerated.end()) return true;
101 auto enum_iter = dev_exts_enumerated->second.find(ext_name);
102 if (enum_iter != dev_exts_enumerated->second.cend()) {
103 return true;
104 }
105 }
106 return false;
107}
108
Tony-LunarG866843d2020-05-13 11:22:42 -0600109bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
110 const VkValidationFeaturesEXT *validation_features) const {
111 bool skip = false;
112 bool debug_printf = false;
113 bool gpu_assisted = false;
114 bool reserve_slot = false;
115 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
116 switch (validation_features->pEnabledValidationFeatures[i]) {
117 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
118 gpu_assisted = true;
119 break;
120
121 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
122 debug_printf = true;
123 break;
124
125 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
126 reserve_slot = true;
127 break;
128
129 default:
130 break;
131 }
132 }
133 if (reserve_slot && !gpu_assisted) {
134 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
135 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
136 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
137 }
138 if (gpu_assisted && debug_printf) {
139 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
140 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
141 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
142 }
143
144 return skip;
145}
146
John Zulauf620755c2018-04-16 11:00:43 -0600147template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700148ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
149 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600150 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700151 ExtEnabled state =
152 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600153 return state;
154}
155
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700156bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500157 const VkAllocationCallbacks *pAllocator,
158 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700159 bool skip = false;
160 // Note: From the spec--
161 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
162 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
163 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700164 ? pCreateInfo->pApplicationInfo->apiVersion
165 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700166 skip |= validate_api_version(local_api_version, api_version);
167 skip |= validate_instance_extensions(pCreateInfo);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700168 const auto *validation_features = LvlFindInChain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
Tony-LunarG866843d2020-05-13 11:22:42 -0600169 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
170
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700171 return skip;
172}
173
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700174void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700175 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
176 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700177 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
178 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700179 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700180 this->instance_extensions = instance_data->instance_extensions;
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700181}
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600182
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700183void StatelessValidation::CommonPostCallRecordEnumeratePhysicalDevice(const VkPhysicalDevice *phys_devices, const int count) {
184 // Assume phys_devices is valid
185 assert(phys_devices);
186 for (int i = 0; i < count; ++i) {
187 const auto &phys_device = phys_devices[i];
188 if (0 == physical_device_properties_map.count(phys_device)) {
189 auto phys_dev_props = new VkPhysicalDeviceProperties;
190 DispatchGetPhysicalDeviceProperties(phys_device, phys_dev_props);
191 physical_device_properties_map[phys_device] = phys_dev_props;
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600192
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700193 // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state
194 uint32_t ext_count = 0;
Jeremy Gebbencbf22862021-03-03 12:01:22 -0700195 layer_data::unordered_set<std::string> dev_exts_enumerated{};
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700196 std::vector<VkExtensionProperties> ext_props{};
197 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, nullptr);
198 ext_props.resize(ext_count);
199 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, ext_props.data());
200 for (uint32_t j = 0; j < ext_count; j++) {
201 dev_exts_enumerated.insert(ext_props[j].extensionName);
202 }
203 device_extensions_enumerated[phys_device] = std::move(dev_exts_enumerated);
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600204 }
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700205 }
206}
207
208void StatelessValidation::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
209 VkPhysicalDevice *pPhysicalDevices, VkResult result) {
210 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
211 return;
212 }
213
214 if (pPhysicalDeviceCount && pPhysicalDevices) {
215 CommonPostCallRecordEnumeratePhysicalDevice(pPhysicalDevices, *pPhysicalDeviceCount);
216 }
217}
218
219void StatelessValidation::PostCallRecordEnumeratePhysicalDeviceGroups(
220 VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties,
221 VkResult result) {
222 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
223 return;
224 }
225
226 if (pPhysicalDeviceGroupCount && pPhysicalDeviceGroupProperties) {
227 for (uint32_t i = 0; i < *pPhysicalDeviceGroupCount; i++) {
228 const auto &group = pPhysicalDeviceGroupProperties[i];
229 CommonPostCallRecordEnumeratePhysicalDevice(group.physicalDevices, group.physicalDeviceCount);
230 }
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600231 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700232}
233
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600234void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
235 for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) {
236 delete (it->second);
237 it = physical_device_properties_map.erase(it);
238 }
239};
240
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700241void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700242 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700243 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700244 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700245 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
246 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700247
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700248 // Parmeter validation also uses extension data
249 stateless_validation->device_extensions = this->device_extensions;
250
251 VkPhysicalDeviceProperties device_properties = {};
252 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600253 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700254 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
255
256 if (device_extensions.vk_nv_shading_rate_image) {
257 // Get the needed shading rate image limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700258 auto shading_rate_image_props = LvlInitStruct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
259 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600260 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700261 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
262 }
263
264 if (device_extensions.vk_nv_mesh_shader) {
265 // Get the needed mesh shader limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700266 auto mesh_shader_props = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesNV>();
267 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600268 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700269 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
270 }
271
Jason Macnak5c954952019-07-09 15:46:12 -0700272 if (device_extensions.vk_nv_ray_tracing) {
273 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700274 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPropertiesNV>();
275 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jason Macnak5c954952019-07-09 15:46:12 -0700276 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500277 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
278 }
279
sourav parmarcd5fb182020-07-17 12:58:44 -0700280 if (device_extensions.vk_khr_ray_tracing_pipeline) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500281 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700282 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>();
283 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500284 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
285 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700286 }
287
sourav parmarcd5fb182020-07-17 12:58:44 -0700288 if (device_extensions.vk_khr_acceleration_structure) {
289 // Get the needed ray tracing acc structure limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700290 auto acc_structure_props = LvlInitStruct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>();
291 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&acc_structure_props);
sourav parmarcd5fb182020-07-17 12:58:44 -0700292 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
293 phys_dev_ext_props.acc_structure_props = acc_structure_props;
294 }
295
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700296 if (device_extensions.vk_ext_transform_feedback) {
297 // Get the needed transform feedback limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700298 auto transform_feedback_props = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
299 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&transform_feedback_props);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700300 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
301 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
302 }
303
Piers Daniellcb6d8032021-04-19 18:51:26 -0600304 if (device_extensions.vk_ext_vertex_attribute_divisor) {
305 // Get the needed vertex attribute divisor limits
306 auto vertex_attribute_divisor_props = LvlInitStruct<VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT>();
307 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&vertex_attribute_divisor_props);
308 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
309 phys_dev_ext_props.vertex_attribute_divisor_props = vertex_attribute_divisor_props;
310 }
311
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800312 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
313
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700314 // Save app-enabled features in this device's validation object
315 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700316 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200317 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
318 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
319 if (features2) {
320 tmp_features2_state.features = features2->features;
321 } else if (pCreateInfo->pEnabledFeatures) {
322 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700323 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200324 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700325 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200326 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700327 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200328 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700329}
330
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700331bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500332 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600333 bool skip = false;
334
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200335 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
336 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
337 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600338 }
339
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700340 // If this device supports VK_KHR_portability_subset, it must be enabled
341 const std::string portability_extension_name("VK_KHR_portability_subset");
342 const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice);
343 const bool portability_supported = dev_extensions.count(portability_extension_name) != 0;
344 bool portability_requested = false;
345
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200346 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
347 skip |=
348 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
349 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
350 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
351 pCreateInfo->ppEnabledExtensionNames[i]);
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700352 if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) {
353 portability_requested = true;
354 }
355 }
356
357 if (portability_supported && !portability_requested) {
358 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451",
359 "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it",
360 report_data->FormatHandle(physicalDevice).c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600361 }
362
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200363 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700364 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
365 bool negative_viewport =
366 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200367 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700368 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
369 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
370 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200371 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600372 }
373
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600374 {
ziga-lunarg9271a7c2021-07-19 16:37:06 +0200375 bool khr_bda =
376 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
377 bool ext_bda =
378 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600379 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700380 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
381 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
382 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600383 }
384 }
385
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600386 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
387 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700388 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600389 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800390 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700391 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800392 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700393 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600394 }
395 }
396
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700397 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500398 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700399 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500400 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
401 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
402 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
403 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700404 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700405 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
406 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
407 skip |= LogError(
408 device,
409 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
410 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
411 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700412 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700413 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600414 if (vertex_attribute_divisor_features && (!device_extensions.vk_ext_vertex_attribute_divisor)) {
415 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
416 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
417 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600418 }
419
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700420 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700421 if (vulkan_11_features) {
422 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
423 while (current) {
424 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
425 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
426 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
427 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
428 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
429 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700430 skip |= LogError(
431 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700432 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
433 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
434 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
435 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
436 break;
437 }
438 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
439 }
sfricke-samsungebda6792021-01-16 08:57:52 -0800440
441 // Check features are enabled if matching extension is passed in as well
442 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
443 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
444 if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
445 (vulkan_11_features->shaderDrawParameters == VK_FALSE)) {
446 skip |= LogError(
447 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-04476",
448 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.",
449 VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
450 }
451 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700452 }
453
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700454 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700455 if (vulkan_12_features) {
456 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
457 while (current) {
458 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
459 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
460 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
461 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
462 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
463 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
464 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
465 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
466 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
467 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
468 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
469 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
470 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700471 skip |= LogError(
472 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700473 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
474 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
475 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
476 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
477 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
478 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
479 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
480 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
481 break;
482 }
483 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
484 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700485 // Check features are enabled if matching extension is passed in as well
486 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
487 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
488 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
489 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
490 skip |= LogError(
491 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
492 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
493 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
494 }
495 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
496 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
497 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
498 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
499 "is not VK_TRUE.",
500 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
501 }
502 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
503 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
504 skip |= LogError(
505 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
506 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
507 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
508 }
509 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
510 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
511 skip |= LogError(
512 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
513 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
514 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
515 }
516 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
517 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
518 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
519 skip |=
520 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
521 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
522 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
523 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
524 }
525 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700526 }
527
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600528 // Validate pCreateInfo->pQueueCreateInfos
529 if (pCreateInfo->pQueueCreateInfos) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600530
531 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700532 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
533 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600534 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700535 skip |=
536 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
537 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
538 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
539 "index value.",
540 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600541 }
542
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700543 if (queue_create_info.pQueuePriorities != nullptr) {
544 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
545 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600546 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700547 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
548 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
549 "] (=%f) is not between 0 and 1 (inclusive).",
550 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600551 }
552 }
553 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700554
555 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700556 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700557 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700558 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700559 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700560 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700561 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700562 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700563 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700564 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700565 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
566 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
567 "protectedMemory feature being set as well.");
568 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600569 }
570 }
571
sfricke-samsung30a57412020-05-15 21:14:54 -0700572 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700573 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700574 VkBool32 variable_pointers = VK_FALSE;
575 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700576 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700577 variable_pointers = vulkan_11_features->variablePointers;
578 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700579 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700580 variable_pointers = variable_pointers_features->variablePointers;
581 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700582 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700583 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700584 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
585 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
586 }
587
sfricke-samsungfd76c342020-05-29 23:13:43 -0700588 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700589 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700590 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700591 VkBool32 multiview_geometry_shader = VK_FALSE;
592 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700593 if (vulkan_11_features) {
594 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700595 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
596 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700597 } else if (multiview_features) {
598 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700599 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
600 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700601 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700602 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700603 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
604 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
605 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700606 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700607 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
608 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
609 }
610
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600611 return skip;
612}
613
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500614bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700615 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700616 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
617 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
618 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600619 }
620
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700621 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600622}
623
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700624bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500625 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100626 bool skip = false;
627
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600628 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700629 skip |=
630 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600631
632 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
633 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
634 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
635 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700636 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
637 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
638 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600639 }
640
641 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
642 // queueFamilyIndexCount uint32_t values
643 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700644 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
645 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
646 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
647 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600648 }
649 }
650
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700651 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
652 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
653 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
654 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
655 }
656
657 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
658 skip |=
659 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
660 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
661 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
662 }
663
664 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
665 skip |=
666 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
667 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
668 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
669 }
670
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600671 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
672 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
673 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
674 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700675 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
676 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
677 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600678 }
679 }
680
681 return skip;
682}
683
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700684bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500685 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600686 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600687
688 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800689 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700690 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600691 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
692 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
693 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
694 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700695 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
696 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
697 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600698 }
699
700 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
701 // queueFamilyIndexCount uint32_t values
702 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700703 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
704 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
705 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
706 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600707 }
708 }
709
Dave Houlton413a6782018-05-22 13:01:54 -0600710 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700711 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600712 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700713 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600714 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700715 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600716
Dave Houlton413a6782018-05-22 13:01:54 -0600717 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700718 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600719 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700720 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600721
Dave Houlton130c0212018-01-29 13:39:56 -0700722 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700723 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
724 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700725 skip |= LogError(
726 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600727 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
728 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700729 }
730
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600731 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100732 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
733 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700734 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
735 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
736 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600737 }
738
739 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700740 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100741 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700742 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
743 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
744 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
745 ") are not equal.",
746 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100747 }
748
749 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700750 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
751 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
752 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
753 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100754 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600755 }
756
757 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700758 skip |= LogError(
759 device, "VUID-VkImageCreateInfo-imageType-00957",
760 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600761 }
762 }
763
Dave Houlton130c0212018-01-29 13:39:56 -0700764 // 3D image may have only 1 layer
765 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700766 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
767 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700768 }
769
Dave Houlton130c0212018-01-29 13:39:56 -0700770 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
771 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
772 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
773 // At least one of the legal attachment bits must be set
774 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700775 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
776 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700777 }
778 // No flags other than the legal attachment bits may be set
779 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
780 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700781 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
782 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700783 }
784 }
785
Jeff Bolzef40fec2018-09-01 22:04:34 -0500786 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700787 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500788 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700789 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700790 ? static_cast<uint32_t>(ceil(log2(max_dim)))
791 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
792 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600793 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700794 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
795 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
796 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600797 }
798
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700799 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700800 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
801 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
802 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600803 }
804
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700805 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700806 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
807 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
808 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100809 }
810
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700811 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700812 skip |= LogError(
813 device, "VUID-VkImageCreateInfo-flags-01924",
814 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
815 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
816 }
817
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600818 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
819 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700820 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
821 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700822 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
823 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
824 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600825 }
826
827 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700828 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600829 // Linear tiling is unsupported
830 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700831 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700832 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
833 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600834 }
835
836 // Sparse 1D image isn't valid
837 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700838 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
839 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600840 }
841
842 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700843 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700844 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
845 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
846 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600847 }
848
849 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700850 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700851 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
852 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
853 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600854 }
855
856 // Multi-sample 2D image when device doesn't support it
857 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700858 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600859 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700860 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
861 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
862 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700863 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600864 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700865 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
866 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
867 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700868 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600869 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700870 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
871 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
872 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700873 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600874 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700875 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
876 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
877 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600878 }
879 }
880 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500881
Jeff Bolz9af91c52018-09-01 21:53:57 -0500882 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
883 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700884 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
885 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
886 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500887 }
888 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700889 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
890 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
891 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500892 }
893 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700894 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
895 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
896 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500897 }
898 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500899
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700900 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600901 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700902 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
903 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
904 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500905 }
906
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700907 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700908 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
909 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800910 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
911 "depth/stencil format.",
912 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500913 }
914
Dave Houlton142c4cb2018-10-17 15:04:41 -0600915 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700916 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
917 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
918 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
919 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500920 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600921 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700922 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
923 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
924 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
925 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500926 }
927 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500928
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700929 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -0800930 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -0700931 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
932 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800933 "format (%s) must be a depth or depth/stencil format.",
934 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -0700935 }
936
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700937 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500938 if (image_stencil_struct != nullptr) {
939 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
940 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
941 // No flags other than the legal attachment bits may be set
942 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
943 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700944 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
945 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
946 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
947 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500948 }
949 }
950
sfricke-samsung61a57c02021-01-10 21:35:12 -0800951 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -0500952 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
953 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800954 skip |= LogError(
955 device, "VUID-VkImageCreateInfo-Format-02536",
956 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
957 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%u) exceeds device "
958 "maxFramebufferWidth (%u)",
959 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500960 }
961
962 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800963 skip |= LogError(
964 device, "VUID-VkImageCreateInfo-format-02537",
965 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
966 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%u) exceeds device "
967 "maxFramebufferHeight (%u)",
968 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500969 }
970 }
971
972 if (!physical_device_features.shaderStorageImageMultisample &&
973 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
974 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
975 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700976 LogError(device, "VUID-VkImageCreateInfo-format-02538",
977 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
978 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
979 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500980 }
981
982 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
983 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700984 skip |= LogError(
985 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500986 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
987 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
988 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
989 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
990 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700991 skip |= LogError(
992 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500993 "vkCreateImage(): Depth-stencil image in which usage does not include "
994 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
995 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
996 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
997 }
998
999 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
1000 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001001 skip |= LogError(
1002 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001003 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1004 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1005 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1006 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1007 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001008 skip |= LogError(
1009 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001010 "vkCreateImage(): Depth-stencil image in which usage does not include "
1011 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1012 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1013 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1014 }
1015 }
1016 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001017
1018 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1019 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1020 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1021 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1022 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1023 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001024
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001025 std::vector<uint64_t> image_create_drm_format_modifiers;
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001026 if (device_extensions.vk_ext_image_drm_format_modifier) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001027 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1028 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001029 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1030 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1031 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1032 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1033 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1034 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1035 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001036 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001037 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1038 } else if (drm_format_mod_list != nullptr) {
1039 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1040 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1041 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001042 }
1043 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1044 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1045 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1046 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1047 "in the pNext chain");
1048 }
1049 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001050
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001051 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001052 bool image_create_maybe_linear = false;
1053 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1054 image_create_maybe_linear = true;
1055 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1056 image_create_maybe_linear = false;
1057 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1058 image_create_maybe_linear =
1059 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001060 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001061 }
1062
1063 // If multi-sample, validate type, usage, tiling and mip levels.
1064 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001065 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001066 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1067 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1068 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1069 }
1070
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001071 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001072 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1073 image_create_maybe_linear)) {
1074 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1075 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1076 }
1077
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001078 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1079 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1080 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1081 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1082 "imageType must be VK_IMAGE_TYPE_2D.");
1083 }
1084 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1085 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1086 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1087 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1088 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001089 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001090 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001091 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1092 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1093 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1094 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1095 }
1096 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1097 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1098 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1099 "imageType must be VK_IMAGE_TYPE_2D.");
1100 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001101 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001102 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1103 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1104 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1105 }
1106 if (pCreateInfo->mipLevels != 1) {
1107 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1108 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1109 pCreateInfo->mipLevels);
1110 }
1111 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001112
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001113 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001114 if (swapchain_create_info != nullptr) {
1115 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1116 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1117 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1118 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1119 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1120 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1121
1122 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1123 // also implicitly forces the check above that extent.depth is 1
1124 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1125 string_VkImageType(pCreateInfo->imageType));
1126 }
1127 if (pCreateInfo->mipLevels != 1) {
1128 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1129 pCreateInfo->mipLevels);
1130 }
1131 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1132 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1133 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1134 }
1135 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1136 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1137 base_message, string_VkImageTiling(pCreateInfo->tiling));
1138 }
1139 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1140 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1141 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1142 }
1143 const VkImageCreateFlags valid_flags =
1144 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001145 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001146 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001147 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001148 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001149 }
1150 }
1151 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001152
1153 // If Chroma subsampled format ( _420_ or _422_ )
1154 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1155 skip |=
1156 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1157 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1158 ") must be a multiple of 2.",
1159 string_VkFormat(image_format), pCreateInfo->extent.width);
1160 }
1161 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1162 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1163 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1164 ") must be a multiple of 2.",
1165 string_VkFormat(image_format), pCreateInfo->extent.height);
1166 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001167
1168 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1169 if (format_list_info) {
1170 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1171 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1172 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1173 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
1174 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1.",
1175 viewFormatCount);
1176 }
1177 // Check if viewFormatCount is not zero that it is all compatible
1178 for (uint32_t i = 0; i < viewFormatCount; i++) {
1179 if (FormatCompatibilityClass(format_list_info->pViewFormats[i]) != FormatCompatibilityClass(image_format)) {
1180 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-04737",
1181 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%u] (%s) and "
1182 "VkImageCreateInfo::format (%s) are not compatible.",
1183 i, string_VkFormat(format_list_info->pViewFormats[0]), string_VkFormat(image_format));
1184 }
1185 }
1186 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001187 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001188
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001189 return skip;
1190}
1191
Jeff Bolz99e3f632020-03-24 22:59:22 -05001192bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1193 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1194 bool skip = false;
1195
1196 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001197 // Validate feature set if using CUBE_ARRAY
1198 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1199 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1200 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1201 "enabling the imageCubeArray feature.");
1202 }
1203
Jeff Bolz99e3f632020-03-24 22:59:22 -05001204 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1205 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1206 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001207 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001208 pCreateInfo->subresourceRange.layerCount);
1209 }
1210 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001211 skip |= LogError(
1212 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1213 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1214 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001215 }
1216 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001217
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001218 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001219 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1220 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1221 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1222 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1223 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1224 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1225 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1226 }
1227 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1228 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1229 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1230 "not an ASTC format.",
1231 string_VkFormat(pCreateInfo->format));
1232 }
1233 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001234
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001235 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001236 if (ycbcr_conversion != nullptr) {
1237 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1238 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1239 skip |= LogError(
1240 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1241 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1242 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1243 "r swizzle = %s\n"
1244 "g swizzle = %s\n"
1245 "b swizzle = %s\n"
1246 "a swizzle = %s\n",
1247 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1248 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1249 }
1250 }
1251 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001252 }
1253 return skip;
1254}
1255
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001256bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001257 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001258 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001259
1260 // Note: for numerical correctness
1261 // - float comparisons should expect NaN (comparison always false).
1262 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1263
1264 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001265 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001266 if (v1_f <= 0.0f) return true;
1267
1268 float intpart;
1269 const float fract = modff(v1_f, &intpart);
1270
1271 assert(std::numeric_limits<float>::radix == 2);
1272 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1273 if (intpart >= u32_max_plus1) return false;
1274
1275 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001276 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001277 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001278 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001279 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001280 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001281 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001282 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001283 };
1284
1285 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1286 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1287 return (v1_f <= v2_f);
1288 };
1289
1290 // width
1291 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001292 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001293
1294 if (!(viewport.width > 0.0f)) {
1295 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001296 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1297 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001298 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1299 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001300 skip |= LogError(object, "VUID-VkViewport-width-01771",
1301 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1302 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001303 }
1304
1305 // height
1306 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001307 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001308 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001309
1310 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1311 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001312 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1313 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001314 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1315 height_healthy = false;
1316
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001317 skip |= LogError(object, "VUID-VkViewport-height-01773",
1318 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1319 ").",
1320 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001321 }
1322
1323 // x
1324 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001325 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001326 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001327 skip |= LogError(object, "VUID-VkViewport-x-01774",
1328 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1329 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001330 }
1331
1332 // x + width
1333 if (x_healthy && width_healthy) {
1334 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001335 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001336 skip |= LogError(
1337 object, "VUID-VkViewport-x-01232",
1338 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1339 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1340 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001341 }
1342 }
1343
1344 // y
1345 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001346 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001347 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001348 skip |= LogError(object, "VUID-VkViewport-y-01775",
1349 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1350 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001351 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001352 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001353 skip |= LogError(object, "VUID-VkViewport-y-01776",
1354 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1355 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001356 }
1357
1358 // y + height
1359 if (y_healthy && height_healthy) {
1360 const float boundary = viewport.y + viewport.height;
1361
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001362 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001363 skip |= LogError(object, "VUID-VkViewport-y-01233",
1364 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1365 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1366 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001367 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001368 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001369 LogError(object, "VUID-VkViewport-y-01777",
1370 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1371 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1372 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001373 }
1374 }
1375
sfricke-samsungfd06d422021-01-22 02:17:21 -08001376 // The extension was not created with a feature bit whichs prevents displaying the 2 variations of the VUIDs
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001377 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001378 // minDepth
1379 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001380 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001381 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001382 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1383 "[0.0, 1.0] range.",
1384 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001385 }
1386
1387 // maxDepth
1388 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001389 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001390 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001391 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1392 "[0.0, 1.0] range.",
1393 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001394 }
1395 }
1396
1397 return skip;
1398}
1399
Dave Houlton142c4cb2018-10-17 15:04:41 -06001400struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001401 VkShadingRatePaletteEntryNV shadingRate;
1402 uint32_t width;
1403 uint32_t height;
1404};
1405
1406// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001407static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001408 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1409 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1410 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1411 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1412 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1413 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001414};
1415
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001416bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001417 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001418
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001419 SampleOrderInfo *sample_order_info;
1420 uint32_t info_idx = 0;
1421 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1422 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1423 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001424 break;
1425 }
1426 }
1427
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001428 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001429 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1430 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1431 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001432 return skip;
1433 }
1434
Dave Houlton142c4cb2018-10-17 15:04:41 -06001435 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001436 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001437 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1438 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1439 ") must "
1440 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1441 "is set in framebufferNoAttachmentsSampleCounts.",
1442 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001443 }
1444
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001445 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001446 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1447 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1448 ") must "
1449 "be equal to the product of sampleCount (=%" PRIu32
1450 "), the fragment width for shadingRate "
1451 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001452 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001453 }
1454
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001455 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001456 skip |= LogError(
1457 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001458 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1459 ") must "
1460 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001461 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001462 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001463
1464 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001465 // the first width*height*sampleCount bits to all be set. Note: There is no
1466 // guarantee that 64 bits is enough, but practically it's unlikely for an
1467 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001468 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001469 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001470 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001471 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1472 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001473 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1474 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001475 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001476 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001477 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1478 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001479 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001480 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001481 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1482 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001483 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001484 uint32_t idx =
1485 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1486 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001487 }
1488
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001489 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1490 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001491 skip |= LogError(
1492 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001493 "The array pSampleLocations must contain exactly one entry for "
1494 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001495 }
1496
1497 return skip;
1498}
1499
sfricke-samsung51303fb2021-05-09 19:09:13 -07001500bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1501 const VkAllocationCallbacks *pAllocator,
1502 VkPipelineLayout *pPipelineLayout) const {
1503 bool skip = false;
1504 // Validate layout count against device physical limit
1505 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1506 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
1507 "vkCreatePipelineLayout(): setLayoutCount (%d) exceeds physical device maxBoundDescriptorSets limit (%d).",
1508 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1509 }
1510
1511 // Validate Push Constant ranges
1512 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1513 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1514 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1515 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1516 // Check that offset + size don't exceed the max.
1517 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1518 if (offset >= max_push_constants_size) {
1519 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
1520 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) that exceeds this "
1521 "device's maxPushConstantSize of %u.",
1522 i, offset, max_push_constants_size);
1523 }
1524 if (size > max_push_constants_size - offset) {
1525 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
1526 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u] offset (%u) and size (%u) "
1527 "together exceeds this device's maxPushConstantSize of %u.",
1528 i, offset, size, max_push_constants_size);
1529 }
1530
1531 // size needs to be non-zero and a multiple of 4.
1532 if (size == 0) {
1533 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
1534 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not greater than zero.",
1535 i, size);
1536 }
1537 if (size & 0x3) {
1538 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
1539 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not a multiple of 4.", i,
1540 size);
1541 }
1542
1543 // offset needs to be a multiple of 4.
1544 if ((offset & 0x3) != 0) {
1545 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
1546 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) is not a multiple of 4.",
1547 i, offset);
1548 }
1549 }
1550
1551 // As of 1.0.28, there is a VU that states that a stage flag cannot appear more than once in the list of push constant ranges.
1552 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1553 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1554 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
1555 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1556 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %d and %d.", i, j);
1557 }
1558 }
1559 }
1560 return skip;
1561}
1562
ziga-lunargc6341372021-07-28 12:57:42 +02001563bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1564 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1565 bool skip = false;
1566
1567 const auto *required_subgroup_size_features =
1568 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1569
1570 if (required_subgroup_size_features) {
1571 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1572 skip |= LogError(
1573 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1574 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1575 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1576 func_name, msg, pCreateInfo->flags);
1577 }
1578 }
1579
1580 return skip;
1581}
1582
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001583bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1584 uint32_t createInfoCount,
1585 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1586 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001587 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001588 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001589
1590 if (pCreateInfos != nullptr) {
1591 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001592 bool has_dynamic_viewport = false;
1593 bool has_dynamic_scissor = false;
1594 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001595 bool has_dynamic_depth_bias = false;
1596 bool has_dynamic_blend_constant = false;
1597 bool has_dynamic_depth_bounds = false;
1598 bool has_dynamic_stencil_compare = false;
1599 bool has_dynamic_stencil_write = false;
1600 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001601 bool has_dynamic_viewport_w_scaling_nv = false;
1602 bool has_dynamic_discard_rectangle_ext = false;
1603 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001604 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001605 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001606 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001607 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001608 bool has_dynamic_cull_mode = false;
1609 bool has_dynamic_front_face = false;
1610 bool has_dynamic_primitive_topology = false;
1611 bool has_dynamic_viewport_with_count = false;
1612 bool has_dynamic_scissor_with_count = false;
1613 bool has_dynamic_vertex_input_binding_stride = false;
1614 bool has_dynamic_depth_test_enable = false;
1615 bool has_dynamic_depth_write_enable = false;
1616 bool has_dynamic_depth_compare_op = false;
1617 bool has_dynamic_depth_bounds_test_enable = false;
1618 bool has_dynamic_stencil_test_enable = false;
1619 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001620 bool has_patch_control_points = false;
1621 bool has_rasterizer_discard_enable = false;
1622 bool has_depth_bias_enable = false;
1623 bool has_logic_op = false;
1624 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001625 bool has_dynamic_vertex_input = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001626 if (pCreateInfos[i].pDynamicState != nullptr) {
1627 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1628 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1629 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001630 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1631 if (has_dynamic_viewport == true) {
1632 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1633 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1634 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1635 i);
1636 }
1637 has_dynamic_viewport = true;
1638 }
1639 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1640 if (has_dynamic_scissor == true) {
1641 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1642 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1643 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1644 i);
1645 }
1646 has_dynamic_scissor = true;
1647 }
1648 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1649 if (has_dynamic_line_width == true) {
1650 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1651 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1652 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1653 i);
1654 }
1655 has_dynamic_line_width = true;
1656 }
1657 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1658 if (has_dynamic_depth_bias == true) {
1659 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1660 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1661 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1662 i);
1663 }
1664 has_dynamic_depth_bias = true;
1665 }
1666 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1667 if (has_dynamic_blend_constant == true) {
1668 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1669 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1670 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1671 i);
1672 }
1673 has_dynamic_blend_constant = true;
1674 }
1675 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1676 if (has_dynamic_depth_bounds == true) {
1677 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1678 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1679 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1680 i);
1681 }
1682 has_dynamic_depth_bounds = true;
1683 }
1684 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1685 if (has_dynamic_stencil_compare == true) {
1686 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1687 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1688 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1689 i);
1690 }
1691 has_dynamic_stencil_compare = true;
1692 }
1693 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1694 if (has_dynamic_stencil_write == true) {
1695 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1696 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1697 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1698 i);
1699 }
1700 has_dynamic_stencil_write = true;
1701 }
1702 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1703 if (has_dynamic_stencil_reference == true) {
1704 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1705 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1706 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1707 i);
1708 }
1709 has_dynamic_stencil_reference = true;
1710 }
1711 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1712 if (has_dynamic_viewport_w_scaling_nv == true) {
1713 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1714 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1715 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1716 i);
1717 }
1718 has_dynamic_viewport_w_scaling_nv = true;
1719 }
1720 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1721 if (has_dynamic_discard_rectangle_ext == true) {
1722 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1723 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1724 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1725 i);
1726 }
1727 has_dynamic_discard_rectangle_ext = true;
1728 }
1729 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1730 if (has_dynamic_sample_locations_ext == true) {
1731 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1732 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1733 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1734 i);
1735 }
1736 has_dynamic_sample_locations_ext = true;
1737 }
1738 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1739 if (has_dynamic_exclusive_scissor_nv == true) {
1740 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1741 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1742 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1743 i);
1744 }
1745 has_dynamic_exclusive_scissor_nv = true;
1746 }
1747 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1748 if (has_dynamic_shading_rate_palette_nv == true) {
1749 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1750 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1751 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1752 i);
1753 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001754 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001755 }
1756 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1757 if (has_dynamic_viewport_course_sample_order_nv == true) {
1758 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1759 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1760 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1761 i);
1762 }
1763 has_dynamic_viewport_course_sample_order_nv = true;
1764 }
1765 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1766 if (has_dynamic_line_stipple == true) {
1767 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1768 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1769 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1770 i);
1771 }
1772 has_dynamic_line_stipple = true;
1773 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001774 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1775 if (has_dynamic_cull_mode) {
1776 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1777 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1778 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1779 i);
1780 }
1781 has_dynamic_cull_mode = true;
1782 }
1783 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1784 if (has_dynamic_front_face) {
1785 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1786 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1787 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1788 i);
1789 }
1790 has_dynamic_front_face = true;
1791 }
1792 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1793 if (has_dynamic_primitive_topology) {
1794 skip |= LogError(
1795 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1796 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1797 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1798 i);
1799 }
1800 has_dynamic_primitive_topology = true;
1801 }
1802 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1803 if (has_dynamic_viewport_with_count) {
1804 skip |= LogError(
1805 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1806 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1807 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1808 i);
1809 }
1810 has_dynamic_viewport_with_count = true;
1811 }
1812 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1813 if (has_dynamic_scissor_with_count) {
1814 skip |= LogError(
1815 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1816 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1817 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1818 i);
1819 }
1820 has_dynamic_scissor_with_count = true;
1821 }
1822 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1823 if (has_dynamic_vertex_input_binding_stride) {
1824 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1825 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1826 "listed twice in the "
1827 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1828 i);
1829 }
1830 has_dynamic_vertex_input_binding_stride = true;
1831 }
1832 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1833 if (has_dynamic_depth_test_enable) {
1834 skip |= LogError(
1835 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1836 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1837 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1838 i);
1839 }
1840 has_dynamic_depth_test_enable = true;
1841 }
1842 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1843 if (has_dynamic_depth_write_enable) {
1844 skip |= LogError(
1845 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1846 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1847 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1848 i);
1849 }
1850 has_dynamic_depth_write_enable = true;
1851 }
1852 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1853 if (has_dynamic_depth_compare_op) {
1854 skip |=
1855 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1856 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1857 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1858 i);
1859 }
1860 has_dynamic_depth_compare_op = true;
1861 }
1862 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1863 if (has_dynamic_depth_bounds_test_enable) {
1864 skip |= LogError(
1865 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1866 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1867 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1868 i);
1869 }
1870 has_dynamic_depth_bounds_test_enable = true;
1871 }
1872 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1873 if (has_dynamic_stencil_test_enable) {
1874 skip |= LogError(
1875 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1876 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1877 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1878 i);
1879 }
1880 has_dynamic_stencil_test_enable = true;
1881 }
1882 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1883 if (has_dynamic_stencil_op) {
1884 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1885 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1886 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1887 i);
1888 }
1889 has_dynamic_stencil_op = true;
1890 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001891 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
1892 // Not allowed for graphics pipelines
1893 skip |= LogError(
1894 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
1895 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
1896 "pCreateInfos[%d].pDynamicState->pDynamicStates[%d] but not allowed in graphic pipelines.",
1897 i, state_index);
1898 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001899 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
1900 if (has_patch_control_points) {
1901 skip |= LogError(
1902 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1903 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
1904 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1905 i);
1906 }
1907 has_patch_control_points = true;
1908 }
1909 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
1910 if (has_rasterizer_discard_enable) {
1911 skip |= LogError(
1912 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1913 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
1914 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1915 i);
1916 }
1917 has_rasterizer_discard_enable = true;
1918 }
1919 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
1920 if (has_depth_bias_enable) {
1921 skip |= LogError(
1922 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1923 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
1924 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1925 i);
1926 }
1927 has_depth_bias_enable = true;
1928 }
1929 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
1930 if (has_logic_op) {
1931 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1932 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
1933 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1934 i);
1935 }
1936 has_logic_op = true;
1937 }
1938 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
1939 if (has_primitive_restart_enable) {
1940 skip |= LogError(
1941 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1942 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
1943 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1944 i);
1945 }
1946 has_primitive_restart_enable = true;
1947 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06001948 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
1949 if (has_dynamic_vertex_input) {
1950 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1951 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
1952 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1953 i);
1954 }
1955 has_dynamic_vertex_input = true;
1956 }
Petr Kraus299ba622017-11-24 03:09:03 +01001957 }
1958 }
1959
sfricke-samsung3b944422021-01-23 02:15:19 -08001960 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
1961 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
1962 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
1963 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1964 i);
1965 }
1966
1967 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
1968 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
1969 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
1970 "both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1971 i);
1972 }
1973
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001974 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04001975 if ((feedback_struct != nullptr) &&
1976 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001977 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1978 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1979 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1980 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1981 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001982 }
1983
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001984 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001985
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001986 // Collect active stages and other information
1987 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001988 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001989 bool has_eval = false;
1990 bool has_control = false;
1991 if (pCreateInfos[i].pStages != nullptr) {
1992 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1993 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1994
1995 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1996 has_control = true;
1997 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1998 has_eval = true;
1999 }
2000
2001 skip |= validate_string(
2002 "vkCreateGraphicsPipelines",
2003 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2004 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
ziga-lunargc6341372021-07-28 12:57:42 +02002005
2006 std::stringstream msg;
2007 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2008 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
2009 &pCreateInfos[i].pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002010 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002011 }
2012
2013 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
2014 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
2015 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2016 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2017 pCreateInfos[i].pTessellationState,
2018 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
2019 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
2020
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002021 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002022 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2023
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002024 skip |= validate_struct_pnext(
2025 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
2026 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
2027 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2028 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2029 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2030 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002031
2032 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
2033 pCreateInfos[i].pTessellationState->flags,
2034 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2035 }
2036
2037 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
2038 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2039 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
2040 pCreateInfos[i].pInputAssemblyState,
2041 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2042 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2043
2044 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
2045 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002046 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002047
2048 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
2049 pCreateInfos[i].pInputAssemblyState->flags,
2050 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2051
2052 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2053 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
2054 pCreateInfos[i].pInputAssemblyState->topology,
2055 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2056
2057 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
2058 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
2059 }
2060
2061 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002062 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002063
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002064 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002065 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2066 "vkCreateGraphicsPipelines: pararameter "
2067 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
2068 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002069 }
2070
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002071 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002072 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
2073 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2074 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
2075 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002076 allowed_structs_vk_pipeline_vertex_input_state_create_info,
2077 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002078 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002079 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2080 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002081 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002082 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2083 skip |=
2084 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2085 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
2086 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
2087 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
2088 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2089
2090 skip |= validate_array(
2091 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2092 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2093 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2094 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2095
2096 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002097 for (uint32_t vertex_binding_description_index = 0;
2098 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
2099 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002100 skip |= validate_ranged_enum(
2101 "vkCreateGraphicsPipelines",
2102 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2103 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002104 pCreateInfos[i]
2105 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
2106 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002107 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2108 }
2109 }
2110
2111 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002112 for (uint32_t vertex_attribute_description_index = 0;
2113 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
2114 ++vertex_attribute_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002115 skip |= validate_ranged_enum(
2116 "vkCreateGraphicsPipelines",
2117 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2118 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002119 pCreateInfos[i]
2120 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2121 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002122 "VUID-VkVertexInputAttributeDescription-format-parameter");
2123 }
2124 }
2125
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002126 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002127 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2128 "vkCreateGraphicsPipelines: pararameter "
2129 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
2130 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2131 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002132 }
2133
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002134 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002135 skip |=
2136 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2137 "vkCreateGraphicsPipelines: pararameter "
2138 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
2139 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2140 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002141 }
2142
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002143 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002144 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2145 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002146 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2147 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002148 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2149 "vkCreateGraphicsPipelines: parameter "
2150 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
2151 "(%" PRIu32 ") is not distinct.",
2152 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002153 }
2154 vertex_bindings.insert(vertex_bind_desc.binding);
2155
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002156 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002157 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2158 "vkCreateGraphicsPipelines: parameter "
2159 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
2160 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2161 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002162 }
2163
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002164 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002165 skip |=
2166 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2167 "vkCreateGraphicsPipelines: parameter "
2168 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
2169 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
2170 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002171 }
2172 }
2173
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002174 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002175 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2176 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002177 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2178 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002179 skip |= LogError(
2180 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002181 "vkCreateGraphicsPipelines: parameter "
2182 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
2183 i, d, vertex_attrib_desc.location);
2184 }
2185 attribute_locations.insert(vertex_attrib_desc.location);
2186
2187 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2188 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002189 skip |= LogError(
2190 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002191 "vkCreateGraphicsPipelines: parameter "
2192 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
2193 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
2194 i, d, vertex_attrib_desc.binding, i);
2195 }
2196
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002197 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002198 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2199 "vkCreateGraphicsPipelines: parameter "
2200 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
2201 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2202 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002203 }
2204
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002205 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002206 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2207 "vkCreateGraphicsPipelines: parameter "
2208 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
2209 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2210 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002211 }
2212
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002213 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002214 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2215 "vkCreateGraphicsPipelines: parameter "
2216 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
2217 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
2218 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002219 }
2220 }
2221 }
2222
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002223 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2224 if (has_control && has_eval) {
2225 if (pCreateInfos[i].pTessellationState == nullptr) {
2226 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
2227 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
2228 "shader stage and a tessellation evaluation shader stage, "
2229 "pCreateInfos[%d].pTessellationState must not be NULL.",
2230 i, i);
2231 } else {
2232 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2233 skip |= validate_struct_pnext(
2234 "vkCreateGraphicsPipelines",
2235 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2236 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2237 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2238 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002239
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002240 skip |= validate_reserved_flags(
2241 "vkCreateGraphicsPipelines",
2242 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2243 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002244
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002245 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2246 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2247 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2248 "vkCreateGraphicsPipelines: invalid parameter "
2249 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
2250 "should be >0 and <=%u.",
2251 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2252 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002253 }
2254 }
2255 }
2256
2257 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2258 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2259 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2260 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002261 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2262 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2263 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2264 "].pViewportState (=NULL) is not a valid pointer.",
2265 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002266 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002267 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2268
2269 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002270 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2271 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2272 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2273 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002274 }
2275
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002276 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002277 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002278 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2279 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002280 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2281 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002282 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002283 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002284 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002285 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002286 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002287 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2288 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002289 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2290 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2291 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002292 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002293
2294 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002295 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002296 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002297 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002298
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002299 auto exclusive_scissor_struct =
2300 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2301 auto shading_rate_image_struct =
2302 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2303 auto coarse_sample_order_struct =
2304 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002305 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002306 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002307 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002308 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002309
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002310 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002311 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002312 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2313 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2314 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2315 ") is not 1.",
2316 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002317 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002318
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002319 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002320 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2321 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2322 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2323 ") is not 1.",
2324 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002325 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002326
Dave Houlton142c4cb2018-10-17 15:04:41 -06002327 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2328 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002329 skip |= LogError(
2330 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2331 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2332 "disabled, but pCreateInfos[%" PRIu32
2333 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2334 ") is not 1.",
2335 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002336 }
2337
Jeff Bolz9af91c52018-09-01 21:53:57 -05002338 if (shading_rate_image_struct &&
2339 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002340 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2341 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2342 "disabled, but pCreateInfos[%" PRIu32
2343 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2344 ") is neither 0 nor 1.",
2345 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002346 }
2347
Petr Krausa6103552017-11-16 21:21:58 +01002348 } else { // multiViewport enabled
2349 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002350 if (!has_dynamic_viewport_with_count) {
2351 skip |= LogError(
2352 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2353 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2354 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002355 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002356 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2357 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2358 "].pViewportState->viewportCount (=%" PRIu32
2359 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2360 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002361 } else if (has_dynamic_viewport_with_count) {
2362 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2363 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2364 "].pViewportState->viewportCount (=%" PRIu32
2365 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2366 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002367 }
Petr Krausa6103552017-11-16 21:21:58 +01002368
2369 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002370 if (!has_dynamic_scissor_with_count) {
2371 skip |= LogError(
2372 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2373 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2374 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002375 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002376 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2377 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2378 "].pViewportState->scissorCount (=%" PRIu32
2379 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2380 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002381 } else if (has_dynamic_scissor_with_count) {
2382 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2383 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2384 "].pViewportState->scissorCount (=%" PRIu32
2385 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2386 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002387 }
2388 }
2389
ziga-lunarg845883b2021-07-14 15:05:00 +02002390 if (!has_dynamic_scissor && viewport_state.pScissors) {
2391 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2392 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002393
2394 if (scissor.offset.x < 0) {
2395 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2396 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2397 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2398 scissor.offset.x, i, scissor_i);
2399 }
2400
2401 if (scissor.offset.y < 0) {
2402 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2403 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2404 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2405 scissor.offset.y, i, scissor_i);
2406 }
2407
ziga-lunarg845883b2021-07-14 15:05:00 +02002408 const int64_t x_sum =
2409 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2410 if (x_sum > std::numeric_limits<int32_t>::max()) {
2411 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2412 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2413 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2414 "] will overflow int32_t.",
2415 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2416 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002417
ziga-lunarg845883b2021-07-14 15:05:00 +02002418 const int64_t y_sum =
2419 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2420 if (y_sum > std::numeric_limits<int32_t>::max()) {
2421 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2422 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2423 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2424 "] will overflow int32_t.",
2425 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2426 }
2427 }
2428 }
2429
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002430 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002431 skip |=
2432 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2433 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2434 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2435 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002436 }
2437
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002438 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002439 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2440 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2441 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2442 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2443 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002444 }
2445
Piers Daniell39842ee2020-07-10 16:42:33 -06002446 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2447 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002448 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2449 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2450 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2451 "].pViewportState->viewportCount (=%" PRIu32 ").",
2452 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002453 }
2454
Dave Houlton142c4cb2018-10-17 15:04:41 -06002455 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002456 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002457 skip |=
2458 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2459 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2460 ") must be zero or identical to pCreateInfos[%" PRIu32
2461 "].pViewportState->viewportCount (=%" PRIu32 ").",
2462 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002463 }
2464
Dave Houlton142c4cb2018-10-17 15:04:41 -06002465 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002466 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002467 skip |= LogError(
2468 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002469 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2470 "] "
2471 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2472 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2473 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002474 }
2475
Petr Krausa6103552017-11-16 21:21:58 +01002476 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002477 skip |= LogError(
2478 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002479 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2480 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002481 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2482 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002483 }
2484
2485 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002486 skip |= LogError(
2487 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002488 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2489 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002490 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2491 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002492 }
2493
Jeff Bolz3e71f782018-08-29 23:15:45 -05002494 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002495 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2496 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2497 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002498 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002499 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2500 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2501 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2502 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002503 }
2504
Jeff Bolz9af91c52018-09-01 21:53:57 -05002505 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002506 shading_rate_image_struct->viewportCount > 0 &&
2507 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002508 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002509 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002510 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002511 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2512 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002513 i, i);
2514 }
2515
Chris Mayer328d8212018-12-11 14:16:18 +01002516 if (vp_swizzle_struct) {
2517 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002518 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2519 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2520 " does "
2521 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2522 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002523 }
2524 }
2525
Petr Krausb3fcdb42018-01-09 22:09:09 +01002526 // validate the VkViewports
2527 if (!has_dynamic_viewport && viewport_state.pViewports) {
2528 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2529 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002530 const char *fn_name = "vkCreateGraphicsPipelines";
2531 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2532 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2533 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002534 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002535 }
2536 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002537
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002538 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002539 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2540 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2541 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2542 "VK_NV_clip_space_w_scaling extension is not enabled.",
2543 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002544 }
2545
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002546 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002547 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2548 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2549 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2550 "VK_EXT_discard_rectangles extension is not enabled.",
2551 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002552 }
2553
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002554 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002555 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2556 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2557 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2558 "VK_EXT_sample_locations extension is not enabled.",
2559 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002560 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002561
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002562 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002563 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2564 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2565 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2566 "VK_NV_scissor_exclusive extension is not enabled.",
2567 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002568 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002569
2570 if (coarse_sample_order_struct &&
2571 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2572 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002573 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2574 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2575 "] "
2576 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2577 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2578 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002579 }
2580
2581 if (coarse_sample_order_struct) {
2582 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002583 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002584 }
2585 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002586
2587 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2588 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002589 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2590 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2591 "] "
2592 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2593 ") "
2594 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2595 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002596 }
2597 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002598 skip |= LogError(
2599 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002600 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2601 "] "
2602 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2603 i);
2604 }
2605 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002606 }
2607
2608 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002609 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2610 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2611 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2612 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002613 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002614 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002615 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002616 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2617 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002618 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002619 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002620 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002621 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002622 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002623 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002624 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002625 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2626 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002627
2628 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002629 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002630 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002631 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002632
2633 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002634 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002635 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2636 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2637
2638 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002639 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002640 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2641 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002642 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002643 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002644
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002645 skip |= validate_flags(
2646 "vkCreateGraphicsPipelines",
2647 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2648 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002649 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002650
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002651 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002652 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002653 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2654 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2655
2656 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002657 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002658 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2659 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2660
2661 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002662 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002663 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2664 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2665 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002666 }
John Zulauf7acac592017-11-06 11:15:53 -07002667 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002668 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002669 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2670 "vkCreateGraphicsPipelines(): parameter "
2671 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2672 i);
John Zulauf7acac592017-11-06 11:15:53 -07002673 }
2674 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2675 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2676 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002677 skip |= LogError(
2678 device,
2679
Dave Houlton413a6782018-05-22 13:01:54 -06002680 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002681 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002682 }
2683 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002684
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002685 const auto *line_state =
2686 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002687
2688 if (line_state) {
2689 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2690 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2691 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2692 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002693 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2694 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2695 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2696 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002697 }
2698 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2699 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002700 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2701 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2702 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2703 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002704 }
2705 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2706 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002707 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2708 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2709 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2710 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002711 }
2712 }
2713 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2714 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2715 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002716 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2717 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2718 "range [1,256].",
2719 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002720 }
2721 }
2722 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002723 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002724 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2725 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002726 skip |=
2727 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2728 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2729 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2730 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002731 }
2732 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2733 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002734 skip |=
2735 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2736 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2737 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2738 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002739 }
2740 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2741 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002742 skip |=
2743 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2744 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2745 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2746 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002747 }
2748 if (line_state->stippledLineEnable) {
2749 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2750 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002751 skip |=
2752 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2753 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2754 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2755 "stippledRectangularLines feature.",
2756 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002757 }
2758 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2759 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002760 skip |=
2761 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2762 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2763 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2764 "stippledBresenhamLines feature.",
2765 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002766 }
2767 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2768 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002769 skip |=
2770 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2771 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2772 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2773 "stippledSmoothLines feature.",
2774 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002775 }
2776 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2777 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002778 skip |=
2779 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2780 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2781 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2782 "stippledRectangularLines and strictLines features.",
2783 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002784 }
2785 }
2786 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002787 }
2788
Petr Krause91f7a12017-12-14 20:57:36 +01002789 bool uses_color_attachment = false;
2790 bool uses_depthstencil_attachment = false;
2791 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002792 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002793 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2794 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002795 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002796 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002797 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002798 }
2799 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002800 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002801 }
Petr Krause91f7a12017-12-14 20:57:36 +01002802 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002803 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002804 }
2805
2806 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002807 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002808 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002809 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002810 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002811 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002812
2813 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002814 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002815 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002816 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002817
2818 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002819 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002820 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2821 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2822
2823 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002824 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002825 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2826 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2827
2828 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002829 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002830 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2831 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002832 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002833
2834 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002835 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002836 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2837 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2838
2839 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002840 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002841 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2842 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2843
2844 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002845 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002846 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2847 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002848 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002849
2850 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002851 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002852 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2853 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002854 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002855
2856 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002857 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002858 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2859 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002860 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002861
2862 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002863 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002864 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2865 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002866 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002867
2868 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002869 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002870 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2871 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002872 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002873
2874 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002875 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002876 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2877 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002878 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002879
2880 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002881 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002882 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2883 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002884 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002885
2886 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002887 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002888 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2889 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002890 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002891
2892 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002893 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002894 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2895 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2896 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002897 }
2898 }
2899
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002900 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002901 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2902
Petr Krause91f7a12017-12-14 20:57:36 +01002903 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002904 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2905 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2906 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2907 pCreateInfos[i].pColorBlendState,
2908 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2909 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2910
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002911 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002912 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002913 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2914 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002915 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2916 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002917 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2918 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002919
2920 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002921 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002922 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002923 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002924
2925 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002926 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002927 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2928 pCreateInfos[i].pColorBlendState->logicOpEnable);
2929
2930 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002931 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002932 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2933 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002934 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002935 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002936
2937 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002938 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
2939 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002940 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002941 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002942 ParameterName::IndexVector{i, attachment_index}),
2943 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002944
2945 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002946 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002947 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002948 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002949 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002950 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002951 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002952
2953 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002954 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002955 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002956 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002957 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002958 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002959 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002960
2961 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002962 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002963 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002964 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002965 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002966 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002967 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002968
2969 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002970 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002971 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002972 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002973 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002974 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002975 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002976
2977 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002978 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002979 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002980 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002981 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002982 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002983 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002984
2985 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002986 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002987 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002988 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002989 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002990 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002991 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002992
2993 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002994 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002995 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002996 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002997 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002998 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002999 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003000 }
3001 }
3002
3003 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003004 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003005 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
3006 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3007 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003008 }
3009
3010 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
3011 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
3012 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003013 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003014 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06003015 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
3016 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003017 }
3018 }
3019 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003020
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003021 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3022 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01003023 if (pCreateInfos[i].basePipelineIndex != -1) {
3024 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003025 skip |=
3026 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003027 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003028 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003029 "and pCreateInfos->basePipelineIndex is not -1.",
3030 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003031 }
3032 }
3033
Petr Kraus9752aae2017-11-24 03:05:50 +01003034 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3035 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003036 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003037 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003038 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003039 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3040 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003041 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003042 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07003043 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003044 skip |=
3045 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
3046 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
3047 "index into the pCreateInfos array, of size %d.",
3048 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003049 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003050 }
3051 }
3052
Petr Kraus9752aae2017-11-24 03:05:50 +01003053 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003054 if (!device_extensions.vk_nv_fill_rectangle) {
3055 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
3056 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003057 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3058 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3059 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3060 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02003061 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3062 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003063 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003064 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003065 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
3066 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3067 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003068 }
3069 } else {
3070 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3071 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
3072 (physical_device_features.fillModeNonSolid == false)) {
3073 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003074 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3075 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003076 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
3077 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3078 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003079 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003080 }
Petr Kraus299ba622017-11-24 03:09:03 +01003081
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003082 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01003083 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003084 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3085 "The line width state is static (pCreateInfos[%" PRIu32
3086 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3087 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3088 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
3089 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003090 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003091 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003092
3093 // Validate no flags not allowed are used
3094 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003095 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
3096 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3097 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3098 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003099 }
3100 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003101 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
3102 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3103 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3104 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003105 }
3106 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3107 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsungad008902021-04-16 01:25:34 -07003108 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3109 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3110 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003111 }
3112 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3113 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsungad008902021-04-16 01:25:34 -07003114 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3115 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3116 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003117 }
3118 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3119 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsungad008902021-04-16 01:25:34 -07003120 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3121 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3122 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003123 }
3124 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3125 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsungad008902021-04-16 01:25:34 -07003126 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3127 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3128 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003129 }
3130 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3131 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsungad008902021-04-16 01:25:34 -07003132 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3133 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3134 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003135 }
3136 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3137 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsungad008902021-04-16 01:25:34 -07003138 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3139 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3140 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003141 }
3142 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3143 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsungad008902021-04-16 01:25:34 -07003144 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3145 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3146 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003147 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003148 }
3149 }
3150
3151 return skip;
3152}
3153
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003154bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3155 uint32_t createInfoCount,
3156 const VkComputePipelineCreateInfo *pCreateInfos,
3157 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003158 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003159 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003160 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003161 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003162 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003163 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003164 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003165 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003166 skip |=
3167 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
3168 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3169 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3170 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003171 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003172
3173 // Make sure compute stage is selected
3174 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003175 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
3176 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
3177 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003178 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003179
sfricke-samsungeb549012021-04-16 01:25:51 -07003180 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3181 // Validate no flags not allowed are used
3182 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
3183 skip |= LogError(
3184 device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3185 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3186 i, flags);
3187 }
3188 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3189 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
3190 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3191 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3192 i, flags);
3193 }
3194 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3195 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
3196 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3197 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3198 i, flags);
3199 }
3200 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3201 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
3202 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3203 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3204 i, flags);
3205 }
3206 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3207 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
3208 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3209 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3210 i, flags);
3211 }
3212 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3213 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
3214 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3215 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3216 i, flags);
3217 }
3218 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3219 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
3220 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3221 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3222 i, flags);
3223 }
3224 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3225 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
3226 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3227 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3228 i, flags);
3229 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003230 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3231 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
3232 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3233 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3234 i, flags);
3235 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003236 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3237 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
3238 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3239 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3240 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003241 }
ziga-lunargc6341372021-07-28 12:57:42 +02003242
3243 std::stringstream msg;
3244 msg << "pCreateInfos[%" << i << "].stage";
3245 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003246 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003247 return skip;
3248}
3249
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003250bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003251 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003252 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003253
3254 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003255 const auto &features = physical_device_features;
3256 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003257
John Zulauf71968502017-10-26 13:51:15 -06003258 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3259 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003260 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3261 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3262 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3263 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003264 }
3265
3266 // Anistropy cannot be enabled in sampler unless enabled as a feature
3267 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003268 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3269 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3270 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003271 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003272 }
John Zulauf71968502017-10-26 13:51:15 -06003273
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003274 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3275 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003276 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3277 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3278 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3279 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003280 }
3281 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003282 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3283 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3284 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3285 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003286 }
3287 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003288 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3289 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3290 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3291 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003292 }
3293 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3294 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3295 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3296 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003297 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3298 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3299 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3300 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3301 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3302 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003303 }
3304 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003305 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3306 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3307 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003308 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003309 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003310 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3311 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3312 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003313 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003314 }
3315
3316 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3317 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003318 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3319 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003320 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003321 if (sampler_reduction != nullptr) {
3322 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3323 skip |= LogError(
3324 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3325 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3326 }
3327 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003328 }
3329
3330 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3331 // valid VkBorderColor value
3332 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3333 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3334 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003335 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3336 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003337 }
3338
John Zulauf275805c2017-10-26 15:34:49 -06003339 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003340 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06003341 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3342 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003343 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3344 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3345 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003346 }
3347 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003348
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003349 // Check for valid Lod range
3350 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003351 skip |=
3352 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3353 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003354 }
3355
3356 // Check mipLodBias to device limit
3357 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003358 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3359 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3360 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003361 }
3362
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003363 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003364 if (sampler_conversion != nullptr) {
3365 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3366 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3367 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3368 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003369 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003370 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003371 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3372 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3373 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3374 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3375 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3376 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3377 }
3378 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003379
3380 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3381 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3382 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3383 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3384 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3385 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3386 }
3387 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3388 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3389 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3390 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3391 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3392 }
3393 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3394 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3395 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3396 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3397 pCreateInfo->minLod, pCreateInfo->maxLod);
3398 }
3399 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3400 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3401 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3402 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3403 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3404 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3405 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3406 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3407 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3408 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3409 }
3410 if (pCreateInfo->anisotropyEnable) {
3411 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3412 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3413 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3414 }
3415 if (pCreateInfo->compareEnable) {
3416 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3417 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3418 "pCreateInfo->compareEnable must be VK_FALSE");
3419 }
3420 if (pCreateInfo->unnormalizedCoordinates) {
3421 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3422 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3423 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3424 }
3425 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003426 }
3427
Tony-LunarG7337b312020-04-15 16:40:25 -06003428 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3429 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3430 if (!device_extensions.vk_ext_custom_border_color) {
3431 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3432 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3433 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3434 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003435 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003436 if (!custom_create_info) {
3437 skip |=
3438 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3439 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3440 "struct in pNext chain.\n",
3441 string_VkBorderColor(pCreateInfo->borderColor));
3442 } else {
3443 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3444 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3445 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3446 !FormatIsSampledFloat(custom_create_info->format)))) {
3447 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3448 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3449 "whose type does not match\n",
3450 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3451 ;
3452 }
3453 }
3454 }
3455
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003456 return skip;
3457}
3458
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003459bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3460 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3461 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003462 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003463 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003464
3465 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3466 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3467 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3468 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003469 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3470 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3471 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3472 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3473 ++descriptor_index) {
3474 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003475 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003476 "vkCreateDescriptorSetLayout: required parameter "
3477 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3478 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003479 }
3480 }
3481 }
3482
3483 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3484 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3485 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003486 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3487 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3488 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3489 "values.",
3490 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003491 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003492
3493 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3494 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3495 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3496 skip |=
3497 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3498 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3499 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3500 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3501 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3502 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003503 }
3504 }
3505 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003506 return skip;
3507}
3508
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003509bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3510 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003511 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003512 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3513 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3514 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003515 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3516 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003517}
3518
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003519bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3520 const VkWriteDescriptorSet *pDescriptorWrites,
3521 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003522 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003523
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003524 if (pDescriptorWrites != NULL) {
3525 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3526 // descriptorCount must be greater than 0
3527 if (pDescriptorWrites[i].descriptorCount == 0) {
3528 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003529 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3530 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003531 }
3532
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003533 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3534 if (validateDstSet) {
3535 // dstSet must be a valid VkDescriptorSet handle
3536 skip |= validate_required_handle(vkCallingFunction,
3537 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3538 pDescriptorWrites[i].dstSet);
3539 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003540
3541 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3542 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3543 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3544 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3545 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3546 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3547 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003548 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3549 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003550 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003551 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3552 "%s(): if pDescriptorWrites[%d].descriptorType is "
3553 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3554 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3555 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3556 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003557 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3558 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003559 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3560 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003561 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3562 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003563 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003564 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3565 ParameterName::IndexVector{i, descriptor_index}),
3566 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003567 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003568 }
3569 }
3570 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3571 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3572 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3573 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3574 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3575 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3576 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003577 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003578 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003579 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3580 "%s(): if pDescriptorWrites[%d].descriptorType is "
3581 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3582 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3583 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3584 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003585 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003586 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003587 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003588 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003589 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3590 ++descriptor_index) {
3591 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3592 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3593 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003594 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3595 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003596 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003597 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3598 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003599 }
3600 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003601 }
3602 }
3603 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3604 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003605 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003606 }
3607
3608 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3609 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003610 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003611 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3612 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003613 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003614 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003615 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3616 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3617 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003618 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003619 }
3620 }
3621 }
3622 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3623 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003624 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003625 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3626 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003627 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003628 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003629 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3630 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3631 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003632 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003633 }
3634 }
3635 }
3636 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003637 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3638 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003639 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003640 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003641 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3642 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3643 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3644 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3645 "accelerationStructureCount %d member equals descriptorCount %d.",
3646 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3647 pDescriptorWrites[i].descriptorCount);
3648 }
3649 // further checks only if we have right structtype
3650 if (pnext_struct) {
3651 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3652 skip |= LogError(
3653 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3654 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3655 ".",
3656 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003657 }
sourav parmarbcee7512020-12-28 14:34:49 -08003658 if (pnext_struct->accelerationStructureCount == 0) {
3659 skip |= LogError(device,
3660 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003661 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003662 }
3663 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003664 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003665 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3666 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3667 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3668 skip |= LogError(device,
3669 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3670 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003671 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003672 }
3673 }
3674 }
sourav parmarbcee7512020-12-28 14:34:49 -08003675 }
3676 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003677 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003678 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3679 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3680 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3681 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3682 "accelerationStructureCount %d member equals descriptorCount %d.",
3683 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3684 pDescriptorWrites[i].descriptorCount);
3685 }
3686 // further checks only if we have right structtype
3687 if (pnext_struct) {
3688 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3689 skip |= LogError(
3690 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3691 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3692 ".",
3693 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003694 }
sourav parmarbcee7512020-12-28 14:34:49 -08003695 if (pnext_struct->accelerationStructureCount == 0) {
3696 skip |= LogError(device,
3697 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003698 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003699 }
3700 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003701 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003702 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3703 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3704 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3705 skip |= LogError(device,
3706 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3707 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003708 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003709 }
3710 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003711 }
3712 }
3713 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003714 }
3715 }
3716 return skip;
3717}
3718
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003719bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3720 const VkWriteDescriptorSet *pDescriptorWrites,
3721 uint32_t descriptorCopyCount,
3722 const VkCopyDescriptorSet *pDescriptorCopies) const {
3723 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3724}
3725
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003726bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003727 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003728 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003729 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3730}
3731
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003732bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3733 const VkAllocationCallbacks *pAllocator,
3734 VkRenderPass *pRenderPass) const {
3735 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3736}
3737
Mike Schuchardt2df08912020-12-15 16:28:09 -08003738bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003739 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003740 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003741 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3742}
3743
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003744bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3745 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003746 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003747 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003748
3749 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3750 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3751 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003752 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3753 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003754 return skip;
3755}
3756
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003757bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003758 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003759 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003760
3761 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3762 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003763 bool cb_is_secondary;
3764 {
3765 auto lock = cb_read_lock();
3766 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3767 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003768
Tony-LunarG3c287f62020-12-17 12:39:49 -07003769 if (cb_is_secondary) {
3770 // Implicit VUs
3771 // validate only sType here; pointer has to be validated in core_validation
3772 const bool k_not_required = false;
3773 const char *k_no_vuid = nullptr;
3774 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3775 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003776 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3777 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003778
Tony-LunarG3c287f62020-12-17 12:39:49 -07003779 if (info) {
3780 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07003781 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
3782 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003783 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003784 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3785 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3786 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3787 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003788
Tony-LunarG3c287f62020-12-17 12:39:49 -07003789 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003790
Tony-LunarG3c287f62020-12-17 12:39:49 -07003791 // Explicit VUs
3792 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003793 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003794 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3795 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3796 cmd_name);
3797 }
3798
3799 if (physical_device_features.inheritedQueries) {
3800 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003801 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3802 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3803 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003804 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003805 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003806 }
3807
3808 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003809 skip |=
3810 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
3811 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
3812 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
3813 } else { // !pipelineStatisticsQuery
3814 skip |=
3815 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
3816 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003817 }
3818
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003819 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003820 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003821 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003822 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3823 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
3824 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003825 commandBuffer,
3826 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07003827 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3828 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3829 }
Petr Kraus139757b2019-08-15 17:19:33 +02003830 }
ziga-lunarg9d019132021-07-19 01:05:31 +02003831
3832 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
3833 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
3834 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
3835 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
3836 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
3837 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
3838 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
3839 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
3840 }
Petr Kraus139757b2019-08-15 17:19:33 +02003841 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003842 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003843 return skip;
3844}
3845
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003846bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003847 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003848 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003849
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003850 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003851 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003852 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3853 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3854 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003855 }
3856 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003857 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3858 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3859 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003860 }
3861 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003862 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003863 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003864 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3865 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3866 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3867 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003868 }
3869 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003870
3871 if (pViewports) {
3872 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3873 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003874 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003875 skip |= manual_PreCallValidateViewport(
3876 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003877 }
3878 }
3879
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003880 return skip;
3881}
3882
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003883bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003884 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003885 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003886
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003887 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003888 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003889 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3890 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3891 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003892 }
3893 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003894 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3895 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3896 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003897 }
3898 } else { // multiViewport enabled
3899 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003900 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003901 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3902 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3903 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3904 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003905 }
3906 }
3907
Petr Kraus6260f0a2018-02-27 21:15:55 +01003908 if (pScissors) {
3909 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3910 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003911
Petr Kraus6260f0a2018-02-27 21:15:55 +01003912 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003913 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3914 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3915 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003916 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003917
Petr Kraus6260f0a2018-02-27 21:15:55 +01003918 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003919 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3920 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3921 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003922 }
3923
3924 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3925 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003926 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3927 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3928 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3929 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003930 }
3931
3932 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3933 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003934 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3935 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3936 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3937 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003938 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003939 }
3940 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003941
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003942 return skip;
3943}
3944
Jeff Bolz5c801d12019-10-09 10:38:45 -05003945bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003946 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003947
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003948 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003949 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3950 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003951 }
3952
3953 return skip;
3954}
3955
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003956bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003957 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003958 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003959
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003960 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003961 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003962 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
3963 }
3964 if (drawCount > device_limits.maxDrawIndirectCount) {
3965 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003966 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
3967 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003968 }
3969 return skip;
3970}
3971
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003972bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003973 VkDeviceSize offset, uint32_t drawCount,
3974 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003975 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003976 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003977 skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
3978 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
3979 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07003980 }
3981 if (drawCount > device_limits.maxDrawIndirectCount) {
3982 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003983 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).",
3984 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003985 }
3986 return skip;
3987}
3988
sfricke-samsungf692b972020-05-02 08:00:45 -07003989bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3990 VkDeviceSize countBufferOffset, bool khr) const {
3991 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003992 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07003993 if (offset & 3) {
3994 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003995 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07003996 }
3997
3998 if (countBufferOffset & 3) {
3999 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004000 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004001 countBufferOffset);
4002 }
4003 return skip;
4004}
4005
4006bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4007 VkDeviceSize offset, VkBuffer countBuffer,
4008 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4009 uint32_t stride) const {
4010 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4011}
4012
4013bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4014 VkDeviceSize offset, VkBuffer countBuffer,
4015 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4016 uint32_t stride) const {
4017 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4018}
4019
4020bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4021 VkDeviceSize countBufferOffset, bool khr) const {
4022 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004023 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004024 if (offset & 3) {
4025 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004026 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004027 }
4028
4029 if (countBufferOffset & 3) {
4030 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004031 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004032 countBufferOffset);
4033 }
4034 return skip;
4035}
4036
4037bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4038 VkDeviceSize offset, VkBuffer countBuffer,
4039 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4040 uint32_t stride) const {
4041 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4042}
4043
4044bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4045 VkDeviceSize offset, VkBuffer countBuffer,
4046 VkDeviceSize countBufferOffset,
4047 uint32_t maxDrawCount, uint32_t stride) const {
4048 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4049}
4050
Tony-LunarG4490de42021-06-21 15:49:19 -06004051bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4052 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4053 uint32_t firstInstance, uint32_t stride) const {
4054 bool skip = false;
4055 if (stride & 3) {
4056 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4057 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4058 }
4059 if (drawCount && nullptr == pVertexInfo) {
4060 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4061 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4062 "one or more valid instances of VkMultiDrawInfoEXT structures");
4063 }
4064 return skip;
4065}
4066
4067bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4068 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4069 uint32_t instanceCount, uint32_t firstInstance,
4070 uint32_t stride, const int32_t *pVertexOffset) const {
4071 bool skip = false;
4072 if (stride & 3) {
4073 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4074 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4075 }
4076 if (drawCount && nullptr == pIndexInfo) {
4077 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4078 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4079 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4080 }
4081 return skip;
4082}
4083
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004084bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4085 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004086 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004087 bool skip = false;
4088 for (uint32_t rect = 0; rect < rectCount; rect++) {
4089 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004090 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
4091 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004092 }
sfricke-samsung10867682020-04-25 02:20:39 -07004093 if (pRects[rect].rect.extent.width == 0) {
4094 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
4095 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
4096 }
4097 if (pRects[rect].rect.extent.height == 0) {
4098 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
4099 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
4100 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004101 }
4102 return skip;
4103}
4104
Andrew Fobel3abeb992020-01-20 16:33:22 -05004105bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4106 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4107 VkImageFormatProperties2 *pImageFormatProperties,
4108 const char *apiName) const {
4109 bool skip = false;
4110
4111 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004112 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004113 if (image_stencil_struct != nullptr) {
4114 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4115 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4116 // No flags other than the legal attachment bits may be set
4117 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4118 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004119 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4120 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4121 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4122 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4123 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004124 }
4125 }
4126 }
4127 }
4128
4129 return skip;
4130}
4131
4132bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4133 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4134 VkImageFormatProperties2 *pImageFormatProperties) const {
4135 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4136 "vkGetPhysicalDeviceImageFormatProperties2");
4137}
4138
4139bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4140 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4141 VkImageFormatProperties2 *pImageFormatProperties) const {
4142 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4143 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4144}
4145
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004146bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4147 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4148 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4149 bool skip = false;
4150
4151 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4152 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4153 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4154 }
4155
4156 return skip;
4157}
4158
sfricke-samsung3999ef62020-02-09 17:05:59 -08004159bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4160 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4161 bool skip = false;
4162
4163 if (pRegions != nullptr) {
4164 for (uint32_t i = 0; i < regionCount; i++) {
4165 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004166 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
4167 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004168 }
4169 }
4170 }
4171 return skip;
4172}
4173
Jeff Leger178b1e52020-10-05 12:22:23 -04004174bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4175 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4176 bool skip = false;
4177
4178 if (pCopyBufferInfo->pRegions != nullptr) {
4179 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4180 if (pCopyBufferInfo->pRegions[i].size == 0) {
4181 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
4182 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
4183 }
4184 }
4185 }
4186 return skip;
4187}
4188
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004189bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004190 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4191 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004192 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004193
4194 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004195 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4196 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4197 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004198 }
4199
4200 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004201 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4202 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4203 "), must be greater than zero and less than or equal to 65536.",
4204 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004205 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004206 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4207 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4208 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004209 }
4210 return skip;
4211}
4212
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004213bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004214 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004215 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004216
4217 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004218 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4219 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4220 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004221 }
4222
4223 if (size != VK_WHOLE_SIZE) {
4224 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004225 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004226 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4227 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004228 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004229 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4230 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004231 }
4232 }
4233 return skip;
4234}
4235
sfricke-samsunga1d00272021-03-10 21:37:41 -08004236bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004237 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004238
4239 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004240 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4241 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4242 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4243 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004244 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004245 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4246 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4247 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004248 }
4249
4250 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4251 // queueFamilyIndexCount uint32_t values
4252 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004253 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004254 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004255 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004256 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4257 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004258 }
4259 }
4260
Dave Houlton413a6782018-05-22 13:01:54 -06004261 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004262 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004263
sfricke-samsunga1d00272021-03-10 21:37:41 -08004264 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4265 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4266 if (format_list_info) {
4267 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4268 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4269 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4270 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
4271 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1 if it is in the pNext chain.",
4272 func_name, viewFormatCount);
4273 }
4274
4275 // Using the first format, compare the rest of the formats against it that they are compatible
4276 for (uint32_t i = 1; i < viewFormatCount; i++) {
4277 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4278 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4279 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4280 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
4281 "VkImageFormatListCreateInfo::pViewFormats[%u] (%s) are not compatible in the pNext chain.",
4282 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4283 string_VkFormat(format_list_info->pViewFormats[i]));
4284 }
4285 }
4286 }
4287
4288 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4289 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4290 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4291 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4292 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4293 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4294 func_name);
4295 } else {
4296 if (format_list_info == nullptr) {
4297 skip |= LogError(
4298 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4299 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4300 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4301 func_name);
4302 } else if (format_list_info->viewFormatCount == 0) {
4303 skip |= LogError(
4304 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4305 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4306 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4307 func_name);
4308 } else {
4309 bool found_base_format = false;
4310 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4311 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4312 found_base_format = true;
4313 break;
4314 }
4315 }
4316 if (!found_base_format) {
4317 skip |=
4318 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4319 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4320 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4321 "pCreateInfo->imageFormat.",
4322 func_name);
4323 }
4324 }
4325 }
4326 }
4327 }
4328 return skip;
4329}
4330
4331bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4332 const VkAllocationCallbacks *pAllocator,
4333 VkSwapchainKHR *pSwapchain) const {
4334 bool skip = false;
4335 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4336 return skip;
4337}
4338
4339bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4340 const VkSwapchainCreateInfoKHR *pCreateInfos,
4341 const VkAllocationCallbacks *pAllocator,
4342 VkSwapchainKHR *pSwapchains) const {
4343 bool skip = false;
4344 if (pCreateInfos) {
4345 for (uint32_t i = 0; i < swapchainCount; i++) {
4346 std::stringstream func_name;
4347 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4348 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4349 }
4350 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004351 return skip;
4352}
4353
Jeff Bolz5c801d12019-10-09 10:38:45 -05004354bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004355 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004356
4357 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004358 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004359 if (present_regions) {
4360 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004361 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004362 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4363 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004364 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004365 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4366 "extension swapchainCount is %i. These values must be equal.",
4367 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004368 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004369 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004370 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4371 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004372 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4373 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4374 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004375 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004376 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004377 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004378 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004379 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004380 }
4381 }
4382
4383 return skip;
4384}
4385
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004386bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4387 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4388 const VkAllocationCallbacks *pAllocator,
4389 VkDisplayModeKHR *pMode) const {
4390 bool skip = false;
4391
4392 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4393 if (display_mode_parameters.visibleRegion.width == 0) {
4394 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4395 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4396 }
4397 if (display_mode_parameters.visibleRegion.height == 0) {
4398 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4399 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4400 }
4401 if (display_mode_parameters.refreshRate == 0) {
4402 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4403 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4404 }
4405
4406 return skip;
4407}
4408
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004409#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004410bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4411 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4412 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004413 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004414 bool skip = false;
4415
4416 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004417 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4418 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004419 }
4420
4421 return skip;
4422}
4423#endif // VK_USE_PLATFORM_WIN32_KHR
4424
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004425bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004426 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004427 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004428 bool skip = false;
4429
4430 if (pCreateInfo) {
4431 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004432 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4433 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004434 }
4435
4436 if (pCreateInfo->pPoolSizes) {
4437 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4438 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004439 skip |= LogError(
4440 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004441 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004442 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004443 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4444 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004445 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4446 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4447 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4448 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4449 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004450 }
Petr Krausc8655be2017-09-27 18:56:51 +02004451 }
4452 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02004453
4454 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
4455 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
4456 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
4457 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
4458 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
4459 }
Petr Krausc8655be2017-09-27 18:56:51 +02004460 }
4461
4462 return skip;
4463}
4464
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004465bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004466 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004467 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004468
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004469 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004470 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004471 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4472 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4473 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004474 }
4475
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004476 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004477 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004478 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4479 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4480 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004481 }
4482
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004483 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004484 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004485 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4486 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4487 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004488 }
4489
4490 return skip;
4491}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004492
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004493bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004494 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004495 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004496
4497 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004498 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
4499 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07004500 }
4501 return skip;
4502}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004503
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004504bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4505 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004506 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004507 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004508
4509 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004510 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004511 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004512 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4513 "vkCmdDispatch(): baseGroupX (%" PRIu32
4514 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4515 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004516 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004517 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4518 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4519 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4520 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004521 }
4522
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004523 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004524 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004525 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4526 "vkCmdDispatch(): baseGroupY (%" PRIu32
4527 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4528 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004529 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004530 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4531 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4532 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4533 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004534 }
4535
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004536 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004537 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004538 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4539 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4540 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4541 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004542 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004543 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4544 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4545 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4546 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004547 }
4548
4549 return skip;
4550}
4551
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004552bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4553 VkPipelineBindPoint pipelineBindPoint,
4554 VkPipelineLayout layout, uint32_t set,
4555 uint32_t descriptorWriteCount,
4556 const VkWriteDescriptorSet *pDescriptorWrites) const {
4557 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4558}
4559
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004560bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4561 uint32_t firstExclusiveScissor,
4562 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004563 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004564 bool skip = false;
4565
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004566 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004567 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004568 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004569 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4570 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4571 ") is not 0.",
4572 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004573 }
4574 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004575 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004576 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4577 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4578 ") is not 1.",
4579 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004580 }
4581 } else { // multiViewport enabled
4582 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004583 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004584 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4585 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4586 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4587 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004588 }
4589 }
4590
Jeff Bolz3e71f782018-08-29 23:15:45 -05004591 if (pExclusiveScissors) {
4592 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4593 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4594
4595 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004596 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4597 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4598 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004599 }
4600
4601 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004602 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4603 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4604 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004605 }
4606
4607 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4608 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004609 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4610 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4611 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4612 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004613 }
4614
4615 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4616 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004617 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4618 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4619 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4620 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004621 }
4622 }
4623 }
4624
4625 return skip;
4626}
4627
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004628bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4629 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004630 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004631 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004632 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4633 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4634 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4635 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4636 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4637 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004638 }
4639
4640 return skip;
4641}
4642
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004643bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4644 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004645 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004646 bool skip = false;
4647
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004648 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004649 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004650 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004651 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4652 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4653 ") is not 0.",
4654 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004655 }
4656 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004657 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004658 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4659 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4660 ") is not 1.",
4661 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004662 }
4663 }
4664
Jeff Bolz9af91c52018-09-01 21:53:57 -05004665 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004666 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004667 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4668 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4669 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4670 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004671 }
4672
4673 return skip;
4674}
4675
Jeff Bolz5c801d12019-10-09 10:38:45 -05004676bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4677 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4678 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004679 bool skip = false;
4680
Dave Houlton142c4cb2018-10-17 15:04:41 -06004681 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004682 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4683 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4684 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004685 }
4686
4687 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004688 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004689 }
4690
4691 return skip;
4692}
4693
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004694bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004695 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004696 bool skip = false;
4697
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004698 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004699 skip |= LogError(
4700 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004701 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4702 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004703 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004704 }
4705
4706 return skip;
4707}
4708
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004709bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4710 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004711 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004712 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004713 static const int condition_multiples = 0b0011;
4714 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004715 skip |= LogError(
4716 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004717 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004718 }
Lockee1c22882019-06-10 16:02:54 -06004719 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004720 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4721 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4722 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4723 stride);
Lockee1c22882019-06-10 16:02:54 -06004724 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004725 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004726 skip |= LogError(
4727 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4728 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004729 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004730 if (drawCount > device_limits.maxDrawIndirectCount) {
4731 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004732 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4733 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004734 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004735 return skip;
4736}
4737
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004738bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4739 VkDeviceSize offset, VkBuffer countBuffer,
4740 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004741 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004742 bool skip = false;
4743
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004744 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004745 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4746 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4747 "), is not a multiple of 4.",
4748 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004749 }
4750
4751 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004752 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4753 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4754 "), is not a multiple of 4.",
4755 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004756 }
4757
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004758 return skip;
4759}
4760
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004761bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004762 const VkAllocationCallbacks *pAllocator,
4763 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004764 bool skip = false;
4765
4766 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4767 if (pCreateInfo != nullptr) {
4768 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4769 // VkQueryPipelineStatisticFlagBits values
4770 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4771 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004772 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4773 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4774 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4775 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004776 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004777 if (pCreateInfo->queryCount == 0) {
4778 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4779 "vkCreateQueryPool(): queryCount must be greater than zero.");
4780 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004781 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004782 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004783}
4784
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004785bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4786 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004787 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004788 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4789 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004790}
4791
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004792void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004793 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4794 VkResult result) {
4795 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004796 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004797}
4798
Mike Schuchardt2df08912020-12-15 16:28:09 -08004799void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004800 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4801 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004802 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004803 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004804 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004805}
4806
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004807void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4808 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004809 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004810 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004811 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004812}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004813
Tony-LunarG3c287f62020-12-17 12:39:49 -07004814void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004815 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004816 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
4817 auto lock = cb_write_lock();
4818 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06004819 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004820 }
4821 }
4822}
4823
4824void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004825 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004826 auto lock = cb_write_lock();
4827 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
4828 secondary_cb_map.erase(pCommandBuffers[cb_index]);
4829 }
4830}
4831
4832void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004833 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004834 auto lock = cb_write_lock();
4835 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
4836 if (item->second == commandPool) {
4837 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004838 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004839 ++item;
4840 }
4841 }
4842}
4843
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004844bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004845 const VkAllocationCallbacks *pAllocator,
4846 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004847 bool skip = false;
4848
4849 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004850 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004851 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004852 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4853 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004854 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004855
4856 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004857 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004858 if (flags_info) {
4859 flags = flags_info->flags;
4860 }
4861
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004862 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004863 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08004864 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004865 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4866 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08004867 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004868 }
4869
4870#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004871 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004872#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004873 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4874 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004875#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004876 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004877#endif
4878
4879 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004880 skip |= LogError(
4881 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004882 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4883 }
4884 if (
4885#ifdef VK_USE_PLATFORM_WIN32_KHR
4886 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4887#endif
4888 (import_memory_fd && import_memory_fd->handleType) ||
4889#ifdef VK_USE_PLATFORM_ANDROID_KHR
4890 (import_memory_ahb && import_memory_ahb->buffer) ||
4891#endif
4892 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004893 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4894 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004895 }
4896 }
4897
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02004898 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
4899 if (export_memory) {
4900 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
4901 if (export_memory_nv) {
4902 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
4903 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
4904 "VkExportMemoryAllocateInfoNV");
4905 }
4906#ifdef VK_USE_PLATFORM_WIN32_KHR
4907 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
4908 if (export_memory_win32_nv) {
4909 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
4910 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
4911 "VkExportMemoryWin32HandleInfoNV");
4912 }
4913#endif
4914 }
4915
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004916 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004917 VkBool32 capture_replay = false;
4918 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004919 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004920 if (vulkan_12_features) {
4921 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4922 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4923 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004924 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004925 if (bda_features) {
4926 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4927 buffer_device_address = bda_features->bufferDeviceAddress;
4928 }
4929 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004930 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004931 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004932 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004933 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004934 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004935 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004936 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004937 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004938 }
4939 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004940 }
4941 return skip;
4942}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004943
Jason Macnak192fa0e2019-07-26 15:07:16 -07004944bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004945 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004946 bool skip = false;
4947
4948 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4949 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4950 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004951 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004952 } else {
4953 uint32_t vertex_component_size = 0;
4954 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4955 vertex_component_size = 4;
4956 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4957 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4958 vertex_component_size = 2;
4959 }
4960 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004961 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004962 }
4963 }
4964
4965 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4966 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004967 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004968 } else {
4969 uint32_t index_element_size = 0;
4970 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4971 index_element_size = 4;
4972 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4973 index_element_size = 2;
4974 }
4975 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004976 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004977 }
4978 }
4979 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4980 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004981 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004982 }
4983 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004984 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004985 }
4986 }
4987
4988 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004989 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004990 }
4991
4992 return skip;
4993}
4994
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004995bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4996 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004997 bool skip = false;
4998
4999 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005000 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005001 }
5002 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005003 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005004 }
5005
5006 return skip;
5007}
5008
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005009bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5010 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005011 bool skip = false;
5012 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005013 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005014 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005015 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005016 }
5017 return skip;
5018}
5019
5020bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005021 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005022 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005023 bool skip = false;
5024 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005025 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5026 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5027 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005028 }
5029 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005030 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5031 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5032 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005033 }
5034 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5035 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005036 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5037 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5038 "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 -07005039 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005040 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005041 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005042 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5043 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005044 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5045 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005046 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005047 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005048 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5049 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5050 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005051 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005052 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005053 uint64_t total_triangle_count = 0;
5054 for (uint32_t i = 0; i < info.geometryCount; i++) {
5055 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005056
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005057 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005058
Jason Macnak5c954952019-07-09 15:46:12 -07005059 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5060 continue;
5061 }
5062 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5063 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005064 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005065 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5066 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5067 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005068 }
5069 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005070 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5071 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5072 for (uint32_t i = 1; i < info.geometryCount; i++) {
5073 const VkGeometryNV &geometry = info.pGeometries[i];
5074 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005075 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005076 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
5077 "info.pGeometries[0].geometryType.",
5078 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005079 }
5080 }
5081 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005082 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5083 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5084 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5085 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5086 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5087 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5088 }
5089 }
5090 skip |=
5091 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005092 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005093 return skip;
5094}
5095
Ricardo Garciaa4935972019-02-21 17:43:18 +01005096bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5097 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005098 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005099 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005100 if (pCreateInfo) {
5101 if ((pCreateInfo->compactedSize != 0) &&
5102 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005103 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5104 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5105 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5106 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005107 }
Jason Macnak5c954952019-07-09 15:46:12 -07005108
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005109 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005110 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005111 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005112 return skip;
5113}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005114
Jeff Bolz5c801d12019-10-09 10:38:45 -05005115bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5116 const VkAccelerationStructureInfoNV *pInfo,
5117 VkBuffer instanceData, VkDeviceSize instanceOffset,
5118 VkBool32 update, VkAccelerationStructureNV dst,
5119 VkAccelerationStructureNV src, VkBuffer scratch,
5120 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005121 bool skip = false;
5122
5123 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005124 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005125 }
5126
5127 return skip;
5128}
5129
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005130bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5131 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5132 VkAccelerationStructureKHR *pAccelerationStructure) const {
5133 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005134 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005135 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005136 if (!acceleration_structure_features ||
5137 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5138 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5139 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5140 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005141 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005142 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5143 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005144 (acceleration_structure_features &&
5145 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005146 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005147 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5148 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5149 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5150 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005151 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005152 if (pCreateInfo->deviceAddress &&
5153 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5154 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5155 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5156 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5157 }
5158 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5159 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005160 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes", pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005161 }
sourav parmar83c31b12020-05-06 12:30:54 -07005162 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005163 return skip;
5164}
5165
Jason Macnak5c954952019-07-09 15:46:12 -07005166bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5167 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005168 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005169 bool skip = false;
5170 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005171 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5172 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005173 }
5174 return skip;
5175}
5176
sourav parmarcd5fb182020-07-17 12:58:44 -07005177bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5178 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5179 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5180 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005181 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005182 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-03432",
5183 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005184 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005185 }
5186 return skip;
5187}
5188
Peter Chen85366392019-05-14 15:20:11 -04005189bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5190 uint32_t createInfoCount,
5191 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5192 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005193 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005194 bool skip = false;
5195
5196 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005197 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5198 std::stringstream msg;
5199 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5200 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
5201 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005202 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005203 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005204 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005205 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5206 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5207 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5208 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005209 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005210
5211 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005212 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005213 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5214 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5215 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5216 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5217 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5218 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5219 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5220 }
5221 }
5222
sourav parmarf4a78252020-04-10 13:04:21 -07005223 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5224 skip |=
5225 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5226 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5227 }
5228 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5229 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5230 skip |=
5231 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5232 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5233 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5234 }
5235 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5236 if (pCreateInfos[i].basePipelineIndex != -1) {
5237 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5238 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5239 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5240 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5241 "and pCreateInfos->basePipelineIndex is not -1.");
5242 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005243 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005244 skip |=
5245 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5246 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5247 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5248 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5249 "that element.");
5250 }
sourav parmarf4a78252020-04-10 13:04:21 -07005251 }
5252 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005253 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005254 skip |=
5255 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5256 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5257 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5258 "commands pCreateInfos parameter.");
5259 }
5260 } else {
5261 if (pCreateInfos[i].basePipelineIndex != -1) {
5262 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5263 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5264 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5265 }
5266 }
5267 }
5268 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5269 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5270 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5271 }
5272 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5273 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5274 "vkCreateRayTracingPipelinesNV: flags must not include "
5275 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5276 }
5277 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5278 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5279 "vkCreateRayTracingPipelinesNV: flags must not include "
5280 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5281 }
5282 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5283 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5284 "vkCreateRayTracingPipelinesNV: flags must not include "
5285 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5286 }
5287 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5288 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5289 "vkCreateRayTracingPipelinesNV: flags must not include "
5290 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5291 }
5292 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5293 skip |= LogError(
5294 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5295 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5296 }
5297 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5298 skip |= LogError(
5299 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5300 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5301 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005302 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5303 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5304 "vkCreateRayTracingPipelinesNV: flags must not include "
5305 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5306 }
5307 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5308 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5309 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5310 }
Peter Chen85366392019-05-14 15:20:11 -04005311 }
5312
5313 return skip;
5314}
5315
sourav parmarcd5fb182020-07-17 12:58:44 -07005316bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5317 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5318 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005319 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005320 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005321 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5322 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5323 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005324 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005325 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005326 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5327 std::stringstream msg;
5328 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5329 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
5330 &pCreateInfos[i].pStages[i]);
5331 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005332 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5333 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5334 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5335 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5336 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5337 }
5338 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5339 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5340 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5341 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
5342 }
5343 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005344 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005345 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
5346 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07005347 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
5348 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
5349 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005350 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
5351 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
5352 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005353 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005354 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005355 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5356 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5357 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5358 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07005359 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07005360 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5361 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5362 }
5363 }
sourav parmarf4a78252020-04-10 13:04:21 -07005364 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005365 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
5366 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07005367 }
5368 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005369 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07005370 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07005371 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
5372 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005373 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005374 }
5375 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5376 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
5377 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07005378 }
5379 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
5380 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
5381 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
5382 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
5383 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
5384 skip |= LogError(
5385 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07005386 "vkCreateRayTracingPipelinesKHR: If flags includes "
5387 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005388 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5389 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
5390 "must not be VK_SHADER_UNUSED_KHR");
5391 }
5392 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
5393 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
5394 skip |= LogError(
5395 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07005396 "vkCreateRayTracingPipelinesKHR: If flags includes "
5397 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005398 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5399 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
5400 "element must not be VK_SHADER_UNUSED_KHR");
5401 }
5402 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005403 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
5404 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
5405 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
5406 skip |= LogError(
5407 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
5408 "vkCreateRayTracingPipelinesKHR: If "
5409 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
5410 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
5411 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5412 }
5413 }
sourav parmarf4a78252020-04-10 13:04:21 -07005414 }
5415 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5416 if (pCreateInfos[i].basePipelineIndex != -1) {
5417 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5418 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07005419 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07005420 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5421 "and pCreateInfos->basePipelineIndex is not -1.");
5422 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005423 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005424 skip |=
5425 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
5426 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
5427 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
5428 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
5429 "element.");
5430 }
sourav parmarf4a78252020-04-10 13:04:21 -07005431 }
5432 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005433 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005434 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005435 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005436 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
5437 "commands pCreateInfos parameter %d.",
5438 pCreateInfos[i].basePipelineIndex, createInfoCount);
5439 }
5440 } else {
5441 if (pCreateInfos[i].basePipelineIndex != -1) {
5442 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07005443 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005444 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5445 }
5446 }
5447 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005448 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
5449 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
5450 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
5451 "vkCreateRayTracingPipelinesKHR: If flags includes "
5452 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
5453 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005454 }
5455 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
5456 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
5457 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
5458 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
5459 "pLibraryInfo and pLibraryInterface must be NULL.");
5460 }
5461 if (pCreateInfos[i].pLibraryInfo) {
5462 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
5463 if (pCreateInfos[i].stageCount == 0) {
5464 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
5465 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5466 "stageCount must not be 0.");
5467 }
5468 if (pCreateInfos[i].groupCount == 0) {
5469 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
5470 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5471 "groupCount must not be 0.");
5472 }
5473 } else {
5474 if (pCreateInfos[i].pLibraryInterface == NULL) {
5475 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
5476 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
5477 "is greater than 0, its "
5478 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005479 }
5480 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005481 }
5482 if (pCreateInfos[i].pLibraryInterface) {
5483 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
5484 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
5485 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
5486 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
5487 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
5488 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005489 }
5490 if (deferredOperation != VK_NULL_HANDLE) {
5491 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
5492 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
5493 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
5494 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07005495 }
5496 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005497 }
5498
5499 return skip;
5500}
5501
Mike Schuchardt21638df2019-03-16 10:52:02 -07005502#ifdef VK_USE_PLATFORM_WIN32_KHR
5503bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
5504 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005505 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07005506 bool skip = false;
5507 if (!device_extensions.vk_khr_swapchain)
5508 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
Mike Schuchardtc57de4a2021-07-20 17:26:32 -07005509 if (!device_extensions.vk_khr_get_surface_capabilities2)
Mike Schuchardt21638df2019-03-16 10:52:02 -07005510 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
5511 if (!device_extensions.vk_khr_surface)
5512 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
Mike Schuchardtc57de4a2021-07-20 17:26:32 -07005513 if (!device_extensions.vk_khr_get_physical_device_properties2)
Mike Schuchardt21638df2019-03-16 10:52:02 -07005514 skip |=
5515 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
5516 if (!device_extensions.vk_ext_full_screen_exclusive)
5517 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
5518 skip |= validate_struct_type(
5519 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
5520 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
5521 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
5522 if (pSurfaceInfo != NULL) {
5523 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
5524 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
5525 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
5526
5527 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
5528 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
5529 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5530 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005531 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5532 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005533
5534 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5535 }
5536 return skip;
5537}
5538#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005539
5540bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5541 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005542 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005543 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5544 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005545 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005546 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5547 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5548 }
5549 return skip;
5550}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005551
5552bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005553 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005554 bool skip = false;
5555
5556 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005557 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
5558 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005559 }
5560
5561 return skip;
5562}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005563
5564bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005565 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005566 bool skip = false;
5567
5568 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005569 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5570 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005571 }
5572
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005573 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005574 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005575 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5576 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005577 }
5578
5579 return skip;
5580}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005581
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005582bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5583 uint32_t bindingCount, const VkBuffer *pBuffers,
5584 const VkDeviceSize *pOffsets) const {
5585 bool skip = false;
5586 if (firstBinding > device_limits.maxVertexInputBindings) {
5587 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5588 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
5589 device_limits.maxVertexInputBindings);
5590 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5591 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
5592 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5593 "maxVertexInputBindings (%u)",
5594 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5595 }
5596
Jeff Bolz165818a2020-05-08 11:19:03 -05005597 for (uint32_t i = 0; i < bindingCount; ++i) {
5598 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005599 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005600 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5601 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5602 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5603 } else {
5604 if (pOffsets[i] != 0) {
5605 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5606 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5607 }
5608 }
5609 }
5610 }
5611
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005612 return skip;
5613}
5614
Mark Lobodzinski84988402019-09-11 15:27:30 -06005615bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005616 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005617 bool skip = false;
5618 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005619 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5620 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005621 }
5622 return skip;
5623}
5624
5625bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005626 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005627 bool skip = false;
5628 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005629 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5630 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005631 }
5632 return skip;
5633}
Petr Kraus3d720392019-11-13 02:52:39 +01005634
5635bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5636 VkSemaphore semaphore, VkFence fence,
5637 uint32_t *pImageIndex) const {
5638 bool skip = false;
5639
5640 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005641 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5642 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005643 }
5644
5645 return skip;
5646}
5647
5648bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5649 uint32_t *pImageIndex) const {
5650 bool skip = false;
5651
5652 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005653 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5654 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005655 }
5656
5657 return skip;
5658}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005659
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005660bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5661 uint32_t firstBinding, uint32_t bindingCount,
5662 const VkBuffer *pBuffers,
5663 const VkDeviceSize *pOffsets,
5664 const VkDeviceSize *pSizes) const {
5665 bool skip = false;
5666
5667 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5668 for (uint32_t i = 0; i < bindingCount; ++i) {
5669 if (pOffsets[i] & 3) {
5670 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5671 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5672 }
5673 }
5674
5675 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5676 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5677 "%s: The firstBinding(%" PRIu32
5678 ") index is greater than or equal to "
5679 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5680 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5681 }
5682
5683 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5684 skip |=
5685 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5686 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5687 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5688 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5689 }
5690
5691 for (uint32_t i = 0; i < bindingCount; ++i) {
5692 // pSizes is optional and may be nullptr.
5693 if (pSizes != nullptr) {
5694 if (pSizes[i] != VK_WHOLE_SIZE &&
5695 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5696 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5697 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5698 ") is not VK_WHOLE_SIZE and is greater than "
5699 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5700 cmd_name, i, pSizes[i]);
5701 }
5702 }
5703 }
5704
5705 return skip;
5706}
5707
5708bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5709 uint32_t firstCounterBuffer,
5710 uint32_t counterBufferCount,
5711 const VkBuffer *pCounterBuffers,
5712 const VkDeviceSize *pCounterBufferOffsets) const {
5713 bool skip = false;
5714
5715 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5716 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5717 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5718 "%s: The firstCounterBuffer(%" PRIu32
5719 ") index is greater than or equal to "
5720 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5721 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5722 }
5723
5724 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5725 skip |=
5726 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5727 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5728 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5729 cmd_name, firstCounterBuffer, counterBufferCount,
5730 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5731 }
5732
5733 return skip;
5734}
5735
5736bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5737 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5738 const VkBuffer *pCounterBuffers,
5739 const VkDeviceSize *pCounterBufferOffsets) const {
5740 bool skip = false;
5741
5742 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5743 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5744 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5745 "%s: The firstCounterBuffer(%" PRIu32
5746 ") index is greater than or equal to "
5747 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5748 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5749 }
5750
5751 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5752 skip |=
5753 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5754 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5755 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5756 cmd_name, firstCounterBuffer, counterBufferCount,
5757 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5758 }
5759
5760 return skip;
5761}
5762
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005763bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5764 uint32_t firstInstance, VkBuffer counterBuffer,
5765 VkDeviceSize counterBufferOffset,
5766 uint32_t counterOffset, uint32_t vertexStride) const {
5767 bool skip = false;
5768
5769 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005770 skip |= LogError(
5771 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005772 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5773 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5774 }
5775
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005776 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08005777 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005778 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005779 }
5780
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005781 return skip;
5782}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005783
5784bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5785 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5786 const VkAllocationCallbacks *pAllocator,
5787 VkSamplerYcbcrConversion *pYcbcrConversion,
5788 const char *apiName) const {
5789 bool skip = false;
5790
5791 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005792 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005793 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005794 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005795 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5796 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005797 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005798 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005799 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005800
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005801#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005802 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005803 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005804#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005805 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005806#endif
5807
sfricke-samsung1a72f942020-07-25 12:09:18 -07005808 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005809
5810 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005811 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005812 const VkComponentMapping components = pCreateInfo->components;
5813 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5814 if (FormatIsXChromaSubsampled(format) == true) {
5815 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5816 skip |=
5817 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005818 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5819 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005820 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005821 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005822
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005823 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5824 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5825 skip |= LogError(
5826 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5827 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5828 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5829 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5830 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005831
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005832 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5833 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5834 skip |=
5835 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005836 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5837 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005838 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005839 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005840
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005841 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5842 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5843 skip |=
5844 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005845 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5846 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005847 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005848 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005849
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005850 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005851 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5852 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5853 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005854 skip |=
5855 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005856 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5857 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005858 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5859 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005860 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005861 }
5862
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005863 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5864 // Checks same VU multiple ways in order to give a more useful error message
5865 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5866 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5867 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5868 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5869 skip |= LogError(
5870 device, vuid,
5871 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5872 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5873 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5874 string_VkComponentSwizzle(components.b));
5875 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005876
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005877 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5878 // 4 channel format = no issue
5879 // 3 = no [a]
5880 // 2 = no [b,a]
5881 // 1 = no [g,b,a]
5882 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5883 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5884
5885 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5886 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5887 skip |= LogError(device, vuid,
5888 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5889 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5890 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5891 string_VkComponentSwizzle(components.b));
5892 } else if ((channels < 3) &&
5893 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5894 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5895 skip |= LogError(device, vuid,
5896 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5897 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5898 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5899 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5900 string_VkComponentSwizzle(components.b));
5901 } else if ((channels < 2) &&
5902 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5903 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5904 skip |= LogError(device, vuid,
5905 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5906 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5907 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5908 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5909 string_VkComponentSwizzle(components.b));
5910 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005911 }
5912 }
5913
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005914 return skip;
5915}
5916
5917bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5918 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5919 const VkAllocationCallbacks *pAllocator,
5920 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5921 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5922 "vkCreateSamplerYcbcrConversion");
5923}
5924
5925bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5926 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5927 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5928 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5929 "vkCreateSamplerYcbcrConversionKHR");
5930}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005931
5932bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5933 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5934 bool skip = false;
5935 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5936 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5937
5938 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005939 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5940 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5941 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5942 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5943 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005944 }
5945 return skip;
5946}
sourav parmara96ab1a2020-04-25 16:28:23 -07005947
5948bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005949 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005950 bool skip = false;
5951 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5952 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5953 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5954 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005955 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005956 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5957 skip |= LogError(
5958 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
5959 "vkCopyAccelerationStructureToMemoryKHR: The "
5960 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5961 }
5962 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
5963 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
5964 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
5965 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
5966 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
5967 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005968 return skip;
5969}
5970
5971bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5972 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5973 bool skip = false;
5974 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5975 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5976 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5977 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5978 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005979 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
5980 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005981 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07005982 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07005983 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005984 return skip;
5985}
5986
5987bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5988 const char *api_name) const {
5989 bool skip = false;
5990 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5991 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5992 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5993 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5994 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5995 api_name);
5996 }
5997 return skip;
5998}
5999
6000bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006001 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006002 bool skip = false;
6003 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006004 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006005 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006006 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006007 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6008 "vkCopyAccelerationStructureKHR: The "
6009 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006010 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006011 return skip;
6012}
6013
6014bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6015 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6016 bool skip = false;
6017 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6018 return skip;
6019}
6020
6021bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006022 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006023 bool skip = false;
6024 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006025 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006026 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6027 }
6028 return skip;
6029}
6030
6031bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006032 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006033 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006034 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006035 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006036 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6037 skip |= LogError(
6038 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6039 "vkCopyMemoryToAccelerationStructureKHR: The "
6040 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006041 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006042 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6043 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006044 return skip;
6045}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006046
sourav parmara96ab1a2020-04-25 16:28:23 -07006047bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6048 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6049 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006050 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006051 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6052 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006053 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006054 pInfo->src.deviceAddress);
6055 }
sourav parmar83c31b12020-05-06 12:30:54 -07006056 return skip;
6057}
6058bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6059 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6060 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6061 bool skip = false;
6062 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6063 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6064 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6065 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6066 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6067 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6068 }
6069 return skip;
6070}
6071bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6072 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6073 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6074 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006075 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006076 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6077 skip |= LogError(
6078 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6079 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6080 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6081 }
sourav parmar83c31b12020-05-06 12:30:54 -07006082 if (dataSize < accelerationStructureCount * stride) {
6083 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6084 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
6085 "accelerationStructureCount (%d) *stride(%zu).",
6086 dataSize, accelerationStructureCount, stride);
6087 }
6088 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6089 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6090 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6091 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6092 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6093 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6094 }
6095 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6096 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6097 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6098 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6099 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6100 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6101 stride);
6102 }
6103 }
6104 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6105 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6106 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6107 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6108 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6109 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6110 stride);
6111 }
6112 }
sourav parmar83c31b12020-05-06 12:30:54 -07006113 return skip;
6114}
6115bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6116 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6117 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006118 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006119 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6120 skip |= LogError(
6121 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6122 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6123 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006124 }
6125 return skip;
6126}
6127
6128bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006129 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6130 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6131 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6132 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006133 uint32_t width, uint32_t height, uint32_t depth) const {
6134 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006135 // RayGen
6136 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6137 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6138 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006139 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006140 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6141 0) {
6142 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6143 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6144 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6145 }
6146 // Callable
6147 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6148 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6149 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6150 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006151 }
6152 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6153 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6154 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006155 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6156 }
6157 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6158 0) {
6159 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6160 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6161 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006162 }
6163 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006164 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6165 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6166 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6167 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006168 }
6169 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6170 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006171 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6172 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006173 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006174 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6175 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
6176 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6177 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6178 }
sourav parmar83c31b12020-05-06 12:30:54 -07006179 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006180 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6181 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
6182 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
6183 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07006184 }
6185 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6186 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
6187 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006188 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6189 }
6190 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6191 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
6192 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6193 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6194 }
6195 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
6196 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
6197 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
6198 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
6199 }
6200 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6201 skip |=
6202 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6203 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6204 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006205 }
6206
sourav parmarcd5fb182020-07-17 12:58:44 -07006207 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6208 skip |=
6209 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6210 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6211 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6212 }
6213
6214 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6215 skip |=
6216 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6217 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6218 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006219 }
6220 return skip;
6221}
6222
sourav parmarcd5fb182020-07-17 12:58:44 -07006223bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6224 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6225 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6226 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006227 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006228 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006229 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6230 skip |= LogError(
6231 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6232 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6233 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006234 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006235 // RayGen
6236 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6237 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6238 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006239 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006240 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6241 0) {
6242 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6243 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6244 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6245 }
6246 // Callabe
6247 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6248 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6249 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6250 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006251 }
6252 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6253 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006254 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6255 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6256 }
6257 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6258 0) {
6259 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6260 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6261 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006262 }
6263 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006264 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6265 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6266 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6267 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006268 }
6269 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6270 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006271 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6272 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006273 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006274 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6275 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6276 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6277 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6278 }
sourav parmar83c31b12020-05-06 12:30:54 -07006279 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006280 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6281 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6282 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6283 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006284 }
6285 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6286 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006287 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6288 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6289 }
6290 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6291 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6292 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6293 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006294 }
6295
sourav parmarcd5fb182020-07-17 12:58:44 -07006296 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
6297 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
6298 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07006299 }
6300 return skip;
6301}
6302bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
6303 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
6304 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
6305 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
6306 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
6307 uint32_t width, uint32_t height, uint32_t depth) const {
6308 bool skip = false;
6309 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6310 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
6311 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
6312 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6313 }
6314 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6315 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
6316 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
6317 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6318 }
6319 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6320 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
6321 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
6322 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
6323 }
6324
6325 // hitShader
6326 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6327 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
6328 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
6329 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6330 }
6331 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6332 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
6333 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
6334 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6335 }
6336 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6337 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
6338 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
6339 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6340 }
6341
6342 // missShader
6343 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6344 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
6345 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
6346 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6347 }
6348 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6349 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
6350 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
6351 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6352 }
6353 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6354 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
6355 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
6356 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6357 }
6358
6359 // raygenShader
6360 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6361 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
6362 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07006363 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6364 }
6365 if (width > device_limits.maxComputeWorkGroupCount[0]) {
6366 skip |=
6367 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
6368 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
6369 }
6370 if (height > device_limits.maxComputeWorkGroupCount[1]) {
6371 skip |=
6372 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
6373 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
6374 }
6375 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
6376 skip |=
6377 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
6378 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07006379 }
6380 return skip;
6381}
6382
sourav parmar83c31b12020-05-06 12:30:54 -07006383bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006384 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
6385 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006386 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006387 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6388 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006389 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
6390 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006391 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07006392 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
6393 }
6394 return skip;
6395}
6396
Piers Daniell39842ee2020-07-10 16:42:33 -06006397bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
6398 const VkViewport *pViewports) const {
6399 bool skip = false;
6400
6401 if (!physical_device_features.multiViewport) {
6402 if (viewportCount != 1) {
6403 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
6404 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
6405 ") is not 1.",
6406 viewportCount);
6407 }
6408 } else { // multiViewport enabled
6409 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
6410 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
6411 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
6412 ") must "
6413 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6414 viewportCount, device_limits.maxViewports);
6415 }
6416 }
6417
6418 if (pViewports) {
6419 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
6420 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
6421 const char *fn_name = "vkCmdSetViewportWithCountEXT";
6422 skip |= manual_PreCallValidateViewport(
6423 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
6424 }
6425 }
6426
6427 return skip;
6428}
6429
6430bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
6431 const VkRect2D *pScissors) const {
6432 bool skip = false;
6433
6434 if (!physical_device_features.multiViewport) {
6435 if (scissorCount != 1) {
6436 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
6437 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6438 ") must "
6439 "be 1 when the multiViewport feature is disabled.",
6440 scissorCount);
6441 }
6442 } else { // multiViewport enabled
6443 if (scissorCount == 0) {
6444 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6445 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6446 ") must "
6447 "be great than zero.",
6448 scissorCount);
6449 } else if (scissorCount > device_limits.maxViewports) {
6450 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6451 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6452 ") must "
6453 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6454 scissorCount, device_limits.maxViewports);
6455 }
6456 }
6457
6458 if (pScissors) {
6459 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
6460 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
6461
6462 if (scissor.offset.x < 0) {
6463 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6464 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
6465 scissor.offset.x);
6466 }
6467
6468 if (scissor.offset.y < 0) {
6469 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6470 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
6471 scissor.offset.y);
6472 }
6473
6474 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
6475 if (x_sum > INT32_MAX) {
6476 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
6477 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6478 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6479 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
6480 }
6481
6482 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
6483 if (y_sum > INT32_MAX) {
6484 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
6485 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6486 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6487 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
6488 }
6489 }
6490 }
6491
6492 return skip;
6493}
6494
6495bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6496 uint32_t bindingCount, const VkBuffer *pBuffers,
6497 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
6498 const VkDeviceSize *pStrides) const {
6499 bool skip = false;
6500 if (firstBinding >= device_limits.maxVertexInputBindings) {
6501 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
6502 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
6503 firstBinding, device_limits.maxVertexInputBindings);
6504 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6505 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
6506 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
6507 "maxVertexInputBindings (%u)",
6508 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6509 }
6510
6511 for (uint32_t i = 0; i < bindingCount; ++i) {
6512 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006513 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06006514 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
6515 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
6516 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
6517 } else {
6518 if (pOffsets[i] != 0) {
6519 skip |=
6520 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
6521 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
6522 }
6523 }
6524 }
6525 if (pStrides) {
6526 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
6527 skip |=
6528 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006529 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%u)", i,
Piers Daniell39842ee2020-07-10 16:42:33 -06006530 pStrides[i], device_limits.maxVertexInputBindingStride);
6531 }
6532 }
6533 }
6534
6535 return skip;
6536}
sourav parmarcd5fb182020-07-17 12:58:44 -07006537
6538bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6539 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6540 bool skip = false;
6541 for (uint32_t i = 0; i < infoCount; ++i) {
6542 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6543 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6544 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6545 }
6546 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6547 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6548 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6549 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6550 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6551 api_name);
6552 }
6553 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6554 skip |=
6555 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6556 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6557 }
6558 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6559 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6560 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6561 }
6562 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6563 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6564 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6565 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6566 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6567 api_name);
6568 }
6569 if (pInfos[i].pGeometries) {
6570 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6571 skip |= validate_ranged_enum(
6572 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6573 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6574 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6575 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006576 skip |= validate_struct_type(
6577 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6578 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6579 &(pInfos[i].pGeometries[j].geometry.triangles),
6580 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6581 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6582 skip |= validate_struct_pnext(
6583 api_name,
6584 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6585 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6586 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6587 skip |=
6588 validate_ranged_enum(api_name,
6589 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6590 ParameterName::IndexVector{i, j}),
6591 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6592 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6593 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6594 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6595 &pInfos[i].pGeometries[j].geometry.triangles,
6596 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6597 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6598 skip |= validate_ranged_enum(
6599 api_name,
6600 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6601 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6602 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6603
6604 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6605 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6606 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6607 }
6608 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6609 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6610 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6611 skip |=
6612 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6613 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6614 api_name);
6615 }
6616 }
6617 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6618 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6619 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6620 &pInfos[i].pGeometries[j].geometry.instances,
6621 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6622 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6623 skip |= validate_struct_type(
6624 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6625 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6626 &(pInfos[i].pGeometries[j].geometry.instances),
6627 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6628 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6629 skip |= validate_struct_pnext(
6630 api_name,
6631 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6632 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6633 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6634
6635 skip |= validate_bool32(api_name,
6636 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6637 ParameterName::IndexVector{i, j}),
6638 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6639 }
6640 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6641 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6642 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6643 &pInfos[i].pGeometries[j].geometry.aabbs,
6644 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6645 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6646 skip |= validate_struct_type(
6647 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6648 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6649 &(pInfos[i].pGeometries[j].geometry.aabbs),
6650 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6651 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6652 skip |= validate_struct_pnext(
6653 api_name,
6654 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6655 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6656 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6657 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6658 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6659 "(%s):stride must be less than or equal to 2^32-1", api_name);
6660 }
6661 }
6662 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6663 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6664 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6665 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6666 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6667 api_name);
6668 }
6669 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6670 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6671 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6672 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6673 "of elements of"
6674 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6675 api_name);
6676 }
6677 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6678 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6679 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6680 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6681 api_name);
6682 }
6683 }
6684 }
6685 }
6686 if (pInfos[i].ppGeometries != NULL) {
6687 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6688 skip |= validate_ranged_enum(
6689 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6690 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6691 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6692 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006693 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6694 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6695 &pInfos[i].ppGeometries[j]->geometry.triangles,
6696 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6697 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6698 skip |= validate_struct_type(
6699 api_name,
6700 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6701 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6702 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6703 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6704 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6705 skip |= validate_struct_pnext(
6706 api_name,
6707 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6708 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6709 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6710 skip |= validate_ranged_enum(api_name,
6711 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6712 ParameterName::IndexVector{i, j}),
6713 "VkFormat", AllVkFormatEnums,
6714 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6715 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6716 skip |= validate_ranged_enum(api_name,
6717 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6718 ParameterName::IndexVector{i, j}),
6719 "VkIndexType", AllVkIndexTypeEnums,
6720 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6721 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6722 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6723 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6724 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6725 }
6726 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6727 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6728 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6729 skip |=
6730 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6731 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6732 api_name);
6733 }
6734 }
6735 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6736 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6737 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6738 &pInfos[i].ppGeometries[j]->geometry.instances,
6739 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6740 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6741 skip |= validate_struct_type(
6742 api_name,
6743 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6744 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6745 &(pInfos[i].ppGeometries[j]->geometry.instances),
6746 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6747 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6748 skip |= validate_struct_pnext(
6749 api_name,
6750 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6751 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6752 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6753 skip |= validate_bool32(api_name,
6754 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6755 ParameterName::IndexVector{i, j}),
6756 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6757 }
6758 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6759 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6760 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6761 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6762 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6763 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6764 skip |= validate_struct_type(
6765 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6766 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6767 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6768 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6769 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6770 skip |= validate_struct_pnext(
6771 api_name,
6772 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6773 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6774 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6775 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6776 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6777 "(%s):stride must be less than or equal to 2^32-1", api_name);
6778 }
6779 }
6780 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6781 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6782 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6783 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6784 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6785 api_name);
6786 }
6787 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6788 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6789 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6790 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6791 "of elements of"
6792 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6793 api_name);
6794 }
6795 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6796 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6797 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6798 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6799 api_name);
6800 }
6801 }
6802 }
6803 }
6804 }
6805 return skip;
6806}
6807bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6808 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6809 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6810 bool skip = false;
6811 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6812 for (uint32_t i = 0; i < infoCount; ++i) {
6813 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6814 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6815 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6816 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6817 "scratchData.deviceAddress member must be a multiple of "
6818 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6819 }
6820 for (uint32_t k = 0; k < infoCount; ++k) {
6821 if (i == k) continue;
6822 bool found = false;
6823 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6824 skip |= LogError(
6825 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6826 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6827 "not be "
6828 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6829 i, k);
6830 found = true;
6831 }
6832 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6833 skip |= LogError(
6834 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
6835 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
6836 "not be "
6837 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6838 i, k);
6839 found = true;
6840 }
6841 if (found) break;
6842 }
6843 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6844 if (pInfos[i].pGeometries) {
6845 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6846 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6847 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6848 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6849 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6850 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6851 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6852 }
6853 } else {
6854 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6855 skip |=
6856 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6857 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6858 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6859 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6860 }
6861 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006862 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006863 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6864 skip |= LogError(
6865 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6866 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6867 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6868 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006869 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6870 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006871 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6872 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6873 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6874 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6875 }
6876 }
6877 } else if (pInfos[i].ppGeometries) {
6878 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6879 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6880 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6881 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6882 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6883 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6884 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6885 }
6886 } else {
6887 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6888 skip |=
6889 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6890 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6891 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6892 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6893 }
6894 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006895 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006896 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6897 skip |= LogError(
6898 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6899 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6900 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6901 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006902 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6903 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006904 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6905 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6906 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6907 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6908 }
6909 }
6910 }
6911 }
6912 }
6913 return skip;
6914}
6915
6916bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
6917 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6918 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
6919 const uint32_t *const *ppMaxPrimitiveCounts) const {
6920 bool skip = false;
6921 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
6922 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006923 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006924 if (!ray_tracing_acceleration_structure_features ||
6925 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
6926 skip |= LogError(
6927 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
6928 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
6929 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
6930 }
6931 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006932 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6933 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6934 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
6935 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
6936 "scratchData.deviceAddress member must be a multiple of "
6937 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6938 }
6939 for (uint32_t k = 0; k < infoCount; ++k) {
6940 if (i == k) continue;
6941 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6942 skip |=
6943 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
6944 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
6945 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
6946 "any other element [%d) of pInfos.",
6947 i, k);
6948 break;
6949 }
6950 }
6951 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6952 if (pInfos[i].pGeometries) {
6953 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6954 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6955 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6956 skip |= LogError(
6957 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6958 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6959 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6960 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6961 }
6962 } else {
6963 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6964 skip |= LogError(
6965 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6966 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6967 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6968 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6969 }
6970 }
6971 }
6972 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6973 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6974 skip |= LogError(
6975 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6976 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6977 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6978 }
6979 }
6980 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6981 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
6982 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6983 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6984 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6985 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6986 }
6987 }
6988 } else if (pInfos[i].ppGeometries) {
6989 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6990 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6991 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6992 skip |= LogError(
6993 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6994 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6995 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6996 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6997 }
6998 } else {
6999 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7000 skip |= LogError(
7001 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7002 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7003 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7004 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7005 }
7006 }
7007 }
7008 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7009 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7010 skip |= LogError(
7011 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7012 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7013 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7014 }
7015 }
7016 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7017 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7018 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7019 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7020 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7021 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7022 }
7023 }
7024 }
7025 }
7026 }
7027 return skip;
7028}
7029
7030bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7031 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7032 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7033 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7034 bool skip = false;
7035 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7036 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007037 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007038 if (!ray_tracing_acceleration_structure_features ||
7039 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7040 skip |=
7041 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7042 "vkBuildAccelerationStructuresKHR: The "
7043 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7044 }
7045 for (uint32_t i = 0; i < infoCount; ++i) {
7046 for (uint32_t j = 0; j < infoCount; ++j) {
7047 if (i == j) continue;
7048 bool found = false;
7049 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7050 skip |= LogError(
7051 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7052 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
7053 "not be "
7054 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7055 i, j);
7056 found = true;
7057 }
7058 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7059 skip |= LogError(
7060 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7061 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
7062 "not be "
7063 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7064 i, j);
7065 found = true;
7066 }
7067 if (found) break;
7068 }
7069 }
7070 return skip;
7071}
7072
7073bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7074 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7075 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7076 bool skip = false;
7077 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7078 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007079 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7080 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007081 if (!(ray_tracing_pipeline_features || ray_query_features) ||
7082 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
7083 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
7084 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
7085 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
7086 }
7087 return skip;
7088}
sfricke-samsungecafb192021-01-17 08:21:14 -08007089
7090bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
7091 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
7092 const VkAllocationCallbacks *pAllocator,
7093 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
7094 bool skip = false;
7095 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
7096 if (private_data_features && private_data_features->privateData == VK_FALSE) {
7097 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
7098 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
7099 }
7100 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07007101}
Piers Daniellcb6d8032021-04-19 18:51:26 -06007102
7103bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7104 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7105 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7106 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7107 bool skip = false;
7108 const auto *vertex_input_dynamic_state_features =
7109 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
7110 const auto *vertex_attribute_divisor_features =
7111 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7112
7113 // VUID-vkCmdSetVertexInputEXT-None-04790
7114 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
7115 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
7116 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
7117 }
7118
7119 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7120 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7121 skip |=
7122 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7123 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7124 }
7125
7126 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7127 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7128 skip |= LogError(
7129 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7130 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7131 }
7132
7133 // VUID-vkCmdSetVertexInputEXT-binding-04793
7134 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7135 bool binding_found = false;
7136 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7137 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
7138 binding_found = true;
7139 break;
7140 }
7141 }
7142 if (!binding_found) {
7143 skip |=
7144 LogError(device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
7145 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u] references an unspecified binding", attribute);
7146 }
7147 }
7148
7149 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
7150 if (vertexBindingDescriptionCount > 1) {
7151 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
7152 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
7153 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
7154 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
7155 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
7156 "vkCmdSetVertexInputEXT(): binding description for binding %u already specified", binding_value);
7157 }
7158 }
7159 }
7160 }
7161
7162 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
7163 if (vertexAttributeDescriptionCount > 1) {
7164 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
7165 uint32_t location = pVertexAttributeDescriptions[attribute].location;
7166 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
7167 if (location == pVertexAttributeDescriptions[next_attribute].location) {
7168 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
7169 "vkCmdSetVertexInputEXT(): attribute description for location %u already specified", location);
7170 }
7171 }
7172 }
7173 }
7174
7175 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7176 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
7177 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
7178 skip |= LogError(
7179 device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
7180 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].binding is greater than maxVertexInputBindings", binding);
7181 }
7182
7183 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
7184 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
7185 skip |= LogError(
7186 device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
7187 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].stride is greater than maxVertexInputBindingStride",
7188 binding);
7189 }
7190
7191 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
7192 if (pVertexBindingDescriptions[binding].divisor == 0 &&
7193 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
7194 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
7195 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is zero but "
7196 "vertexAttributeInstanceRateZeroDivisor is not enabled",
7197 binding);
7198 }
7199
7200 if (pVertexBindingDescriptions[binding].divisor > 1) {
7201 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7202 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7203 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
7204 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than one but "
7205 "vertexAttributeInstanceRateDivisor is not enabled",
7206 binding);
7207 } else {
7208 // VUID-VkVertexInputBindingDescription2EXT-divisor-04800
7209 if (pVertexBindingDescriptions[binding].divisor >
7210 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
7211 skip |= LogError(
7212 device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04800",
7213 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than maxVertexAttribDivisor",
7214 binding);
7215 }
7216
7217 // VUID-VkVertexInputBindingDescription2EXT-divisor-04801
7218 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
7219 skip |=
7220 LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04801",
7221 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than 1 but inputRate "
7222 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7223 binding);
7224 }
7225 }
7226 }
7227 }
7228
7229 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7230 // VUID-VkVertexInputAttributeDescription2EXT-location-04802
7231 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
7232 skip |= LogError(
7233 device, "VUID-VkVertexInputAttributeDescription2EXT-location-04802",
7234 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].location is greater than maxVertexInputAttributes",
7235 attribute);
7236 }
7237
7238 // VUID-VkVertexInputAttributeDescription2EXT-binding-04803
7239 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
7240 skip |= LogError(
7241 device, "VUID-VkVertexInputAttributeDescription2EXT-binding-04803",
7242 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].binding is greater than maxVertexInputBindings",
7243 attribute);
7244 }
7245
7246 // VUID-VkVertexInputAttributeDescription2EXT-offset-04804
7247 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
7248 skip |= LogError(
7249 device, "VUID-VkVertexInputAttributeDescription2EXT-offset-04804",
7250 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].offset is greater than maxVertexInputAttributeOffset",
7251 attribute);
7252 }
7253
7254 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7255 VkFormatProperties properties;
7256 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7257 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7258 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
7259 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].format is not a "
7260 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7261 attribute);
7262 }
7263 }
7264
7265 return skip;
7266}
sfricke-samsung51303fb2021-05-09 19:09:13 -07007267
7268bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
7269 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
7270 const void *pValues) const {
7271 bool skip = false;
7272 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
7273 // Check that offset + size don't exceed the max.
7274 // Prevent arithetic overflow here by avoiding addition and testing in this order.
7275 if (offset >= max_push_constants_size) {
7276 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00370",
7277 "vkCmdPushConstants(): offset (%u) that exceeds this device's maxPushConstantSize of %u.", offset,
7278 max_push_constants_size);
7279 }
7280 if (size > max_push_constants_size - offset) {
7281 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
7282 "vkCmdPushConstants(): offset (%u) and size (%u) that exceeds this device's maxPushConstantSize of %u.",
7283 offset, size, max_push_constants_size);
7284 }
7285
7286 // size needs to be non-zero and a multiple of 4.
7287 if (size & 0x3) {
7288 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369", "vkCmdPushConstants(): size (%u) must be a multiple of 4.",
7289 size);
7290 }
7291
7292 // offset needs to be a multiple of 4.
7293 if ((offset & 0x3) != 0) {
7294 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007295 "vkCmdPushConstants(): offset (%u) must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007296 }
7297 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007298}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02007299
7300bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
7301 uint32_t srcCacheCount,
7302 const VkPipelineCache *pSrcCaches) const {
7303 bool skip = false;
7304 if (pSrcCaches) {
7305 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
7306 if (pSrcCaches[index0] == dstCache) {
7307 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
7308 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
7309 report_data->FormatHandle(dstCache).c_str());
7310 break;
7311 }
7312 }
7313 }
7314 return skip;
7315}