blob: b0e27012e03687f0f30716685fabca6e07562875 [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
ziga-lunarga283d022021-08-04 18:35:23 +0200312 if (device_extensions.vk_ext_blend_operation_advanced) {
313 // Get the needed vertex attribute divisor limits
314 auto blend_operation_advanced_props = LvlInitStruct<VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT>();
315 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&blend_operation_advanced_props);
316 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
317 phys_dev_ext_props.blend_operation_advanced_props = blend_operation_advanced_props;
318 }
319
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800320 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
321
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700322 // Save app-enabled features in this device's validation object
323 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700324 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200325 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
326 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
327 if (features2) {
328 tmp_features2_state.features = features2->features;
329 } else if (pCreateInfo->pEnabledFeatures) {
330 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700331 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200332 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700333 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200334 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700335 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200336 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700337}
338
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700339bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500340 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600341 bool skip = false;
342
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200343 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
344 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
345 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600346 }
347
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700348 // If this device supports VK_KHR_portability_subset, it must be enabled
349 const std::string portability_extension_name("VK_KHR_portability_subset");
350 const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice);
351 const bool portability_supported = dev_extensions.count(portability_extension_name) != 0;
352 bool portability_requested = false;
353
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200354 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
355 skip |=
356 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
357 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
358 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
359 pCreateInfo->ppEnabledExtensionNames[i]);
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700360 if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) {
361 portability_requested = true;
362 }
363 }
364
365 if (portability_supported && !portability_requested) {
366 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451",
367 "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it",
368 report_data->FormatHandle(physicalDevice).c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600369 }
370
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200371 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700372 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
373 bool negative_viewport =
374 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200375 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700376 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
377 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
378 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200379 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600380 }
381
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600382 {
ziga-lunarg9271a7c2021-07-19 16:37:06 +0200383 bool khr_bda =
384 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
385 bool ext_bda =
386 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600387 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700388 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
389 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
390 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600391 }
392 }
393
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600394 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
395 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700396 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600397 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800398 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700399 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800400 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700401 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600402 }
403 }
404
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700405 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500406 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700407 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500408 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
409 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
410 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
411 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700412 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700413 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
414 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
415 skip |= LogError(
416 device,
417 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
418 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
419 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700420 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700421 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600422 if (vertex_attribute_divisor_features && (!device_extensions.vk_ext_vertex_attribute_divisor)) {
423 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
424 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
425 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600426 }
427
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700428 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700429 if (vulkan_11_features) {
430 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
431 while (current) {
432 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
433 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
434 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
435 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
436 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
437 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700438 skip |= LogError(
439 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700440 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
441 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
442 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
443 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
444 break;
445 }
446 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
447 }
sfricke-samsungebda6792021-01-16 08:57:52 -0800448
449 // Check features are enabled if matching extension is passed in as well
450 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
451 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
452 if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
453 (vulkan_11_features->shaderDrawParameters == VK_FALSE)) {
454 skip |= LogError(
455 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-04476",
456 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.",
457 VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
458 }
459 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700460 }
461
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700462 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700463 if (vulkan_12_features) {
464 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
465 while (current) {
466 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
467 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
468 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
469 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
470 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
471 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
472 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
473 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
474 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
475 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
476 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
477 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
478 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700479 skip |= LogError(
480 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700481 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
482 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
483 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
484 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
485 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
486 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
487 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
488 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
489 break;
490 }
491 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
492 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700493 // Check features are enabled if matching extension is passed in as well
494 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
495 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
496 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
497 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
498 skip |= LogError(
499 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
500 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
501 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
502 }
503 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
504 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
505 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
506 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
507 "is not VK_TRUE.",
508 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
509 }
510 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
511 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
512 skip |= LogError(
513 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
514 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
515 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
516 }
517 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
518 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
519 skip |= LogError(
520 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
521 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
522 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
523 }
524 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
525 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
526 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
527 skip |=
528 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
529 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
530 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
531 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
532 }
533 }
ziga-lunarg27f88fd2021-08-01 15:47:30 +0200534 if (vulkan_12_features->bufferDeviceAddress == VK_TRUE) {
535 if (IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))) {
536 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-04748",
537 "vkCreateDevice(): pNext chain includes VkPhysicalDeviceVulkan12Features with bufferDeviceAddress "
538 "set to VK_TRUE and ppEnabledExtensionNames contains VK_EXT_buffer_device_address");
539 }
540 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700541 }
542
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600543 // Validate pCreateInfo->pQueueCreateInfos
544 if (pCreateInfo->pQueueCreateInfos) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600545
546 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700547 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
548 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600549 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700550 skip |=
551 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
552 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
553 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
554 "index value.",
555 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600556 }
557
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700558 if (queue_create_info.pQueuePriorities != nullptr) {
559 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
560 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600561 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700562 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
563 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
564 "] (=%f) is not between 0 and 1 (inclusive).",
565 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600566 }
567 }
568 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700569
570 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700571 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700572 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700573 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700574 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700575 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700576 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700577 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700578 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700579 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700580 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
581 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
582 "protectedMemory feature being set as well.");
583 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600584 }
585 }
586
sfricke-samsung30a57412020-05-15 21:14:54 -0700587 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700588 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700589 VkBool32 variable_pointers = VK_FALSE;
590 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700591 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700592 variable_pointers = vulkan_11_features->variablePointers;
593 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700594 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700595 variable_pointers = variable_pointers_features->variablePointers;
596 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700597 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700598 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700599 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
600 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
601 }
602
sfricke-samsungfd76c342020-05-29 23:13:43 -0700603 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700604 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700605 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700606 VkBool32 multiview_geometry_shader = VK_FALSE;
607 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700608 if (vulkan_11_features) {
609 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700610 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
611 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700612 } else if (multiview_features) {
613 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700614 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
615 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700616 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700617 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700618 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
619 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
620 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700621 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700622 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
623 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
624 }
625
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600626 return skip;
627}
628
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500629bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700630 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700631 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
632 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
633 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600634 }
635
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700636 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600637}
638
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700639bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500640 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100641 bool skip = false;
642
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600643 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700644 skip |=
645 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600646
647 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
648 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
649 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
650 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700651 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
652 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
653 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600654 }
655
656 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
657 // queueFamilyIndexCount uint32_t values
658 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700659 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
660 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
661 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
662 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600663 }
664 }
665
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700666 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
667 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
668 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
669 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
670 }
671
672 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
673 skip |=
674 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
675 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
676 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
677 }
678
679 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
680 skip |=
681 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
682 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
683 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
684 }
685
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600686 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
687 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
688 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
689 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700690 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
691 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
692 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600693 }
694 }
695
696 return skip;
697}
698
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700699bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500700 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600701 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600702
703 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800704 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700705 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600706 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
707 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
708 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
709 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700710 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
711 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
712 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600713 }
714
715 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
716 // queueFamilyIndexCount uint32_t values
717 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700718 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
719 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
720 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
721 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600722 }
723 }
724
Dave Houlton413a6782018-05-22 13:01:54 -0600725 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700726 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600727 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700728 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600729 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700730 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600731
Dave Houlton413a6782018-05-22 13:01:54 -0600732 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700733 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600734 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700735 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600736
Dave Houlton130c0212018-01-29 13:39:56 -0700737 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700738 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
739 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700740 skip |= LogError(
741 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600742 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
743 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700744 }
745
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600746 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100747 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
748 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700749 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
750 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
751 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600752 }
753
754 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700755 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100756 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700757 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
758 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
759 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
760 ") are not equal.",
761 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100762 }
763
764 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700765 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
766 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
767 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
768 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100769 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600770 }
771
772 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700773 skip |= LogError(
774 device, "VUID-VkImageCreateInfo-imageType-00957",
775 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600776 }
777 }
778
Dave Houlton130c0212018-01-29 13:39:56 -0700779 // 3D image may have only 1 layer
780 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700781 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
782 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700783 }
784
Dave Houlton130c0212018-01-29 13:39:56 -0700785 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
786 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
787 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
788 // At least one of the legal attachment bits must be set
789 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700790 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
791 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700792 }
793 // No flags other than the legal attachment bits may be set
794 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
795 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700796 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
797 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700798 }
799 }
800
Jeff Bolzef40fec2018-09-01 22:04:34 -0500801 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700802 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500803 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700804 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700805 ? static_cast<uint32_t>(ceil(log2(max_dim)))
806 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
807 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600808 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700809 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
810 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
811 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600812 }
813
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700814 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700815 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
816 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
817 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600818 }
819
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700820 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700821 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
822 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
823 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100824 }
825
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700826 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700827 skip |= LogError(
828 device, "VUID-VkImageCreateInfo-flags-01924",
829 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
830 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
831 }
832
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600833 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
834 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700835 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
836 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700837 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
838 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
839 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600840 }
841
842 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700843 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600844 // Linear tiling is unsupported
845 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700846 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700847 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
848 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600849 }
850
851 // Sparse 1D image isn't valid
852 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700853 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
854 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600855 }
856
857 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700858 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700859 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
860 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
861 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600862 }
863
864 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700865 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700866 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
867 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
868 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600869 }
870
871 // Multi-sample 2D image when device doesn't support it
872 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700873 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600874 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700875 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
876 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
877 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700878 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600879 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700880 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
881 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
882 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700883 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600884 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700885 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
886 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
887 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700888 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600889 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700890 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
891 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
892 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600893 }
894 }
895 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500896
Jeff Bolz9af91c52018-09-01 21:53:57 -0500897 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
898 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700899 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
900 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
901 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500902 }
903 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700904 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
905 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
906 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500907 }
908 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700909 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
910 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
911 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500912 }
913 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500914
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700915 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600916 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700917 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
918 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
919 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500920 }
921
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700922 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700923 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
924 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800925 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
926 "depth/stencil format.",
927 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500928 }
929
Dave Houlton142c4cb2018-10-17 15:04:41 -0600930 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700931 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
932 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
933 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
934 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500935 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600936 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700937 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
938 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
939 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
940 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500941 }
942 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500943
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700944 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -0800945 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -0700946 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
947 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800948 "format (%s) must be a depth or depth/stencil format.",
949 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -0700950 }
951
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700952 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500953 if (image_stencil_struct != nullptr) {
954 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
955 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
956 // No flags other than the legal attachment bits may be set
957 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
958 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700959 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
960 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
961 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
962 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500963 }
964 }
965
sfricke-samsung61a57c02021-01-10 21:35:12 -0800966 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -0500967 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
968 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800969 skip |= LogError(
970 device, "VUID-VkImageCreateInfo-Format-02536",
971 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
972 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%u) exceeds device "
973 "maxFramebufferWidth (%u)",
974 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500975 }
976
977 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsungf3a9b5b2021-01-13 13:05:52 -0800978 skip |= LogError(
979 device, "VUID-VkImageCreateInfo-format-02537",
980 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
981 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%u) exceeds device "
982 "maxFramebufferHeight (%u)",
983 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500984 }
985 }
986
987 if (!physical_device_features.shaderStorageImageMultisample &&
988 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
989 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
990 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700991 LogError(device, "VUID-VkImageCreateInfo-format-02538",
992 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
993 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
994 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500995 }
996
997 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
998 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700999 skip |= LogError(
1000 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001001 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1002 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1003 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1004 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
1005 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001006 skip |= LogError(
1007 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001008 "vkCreateImage(): Depth-stencil image in which usage does not include "
1009 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1010 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1011 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1012 }
1013
1014 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
1015 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001016 skip |= LogError(
1017 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001018 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1019 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1020 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1021 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1022 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001023 skip |= LogError(
1024 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001025 "vkCreateImage(): Depth-stencil image in which usage does not include "
1026 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1027 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1028 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1029 }
1030 }
1031 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001032
1033 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1034 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1035 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1036 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1037 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1038 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001039
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001040 std::vector<uint64_t> image_create_drm_format_modifiers;
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001041 if (device_extensions.vk_ext_image_drm_format_modifier) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001042 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1043 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001044 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1045 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1046 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1047 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1048 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1049 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1050 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001051 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001052 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1053 } else if (drm_format_mod_list != nullptr) {
1054 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1055 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1056 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001057 }
1058 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1059 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1060 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1061 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1062 "in the pNext chain");
1063 }
1064 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001065
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001066 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001067 bool image_create_maybe_linear = false;
1068 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1069 image_create_maybe_linear = true;
1070 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1071 image_create_maybe_linear = false;
1072 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1073 image_create_maybe_linear =
1074 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001075 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001076 }
1077
1078 // If multi-sample, validate type, usage, tiling and mip levels.
1079 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001080 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001081 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1082 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1083 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1084 }
1085
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001086 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001087 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1088 image_create_maybe_linear)) {
1089 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1090 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1091 }
1092
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001093 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1094 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1095 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1096 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1097 "imageType must be VK_IMAGE_TYPE_2D.");
1098 }
1099 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1100 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1101 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1102 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1103 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001104 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001105 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001106 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1107 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1108 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1109 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1110 }
1111 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1112 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1113 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1114 "imageType must be VK_IMAGE_TYPE_2D.");
1115 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001116 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001117 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1118 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1119 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1120 }
1121 if (pCreateInfo->mipLevels != 1) {
1122 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1123 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1124 pCreateInfo->mipLevels);
1125 }
1126 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001127
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001128 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001129 if (swapchain_create_info != nullptr) {
1130 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1131 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1132 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1133 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1134 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1135 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1136
1137 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1138 // also implicitly forces the check above that extent.depth is 1
1139 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1140 string_VkImageType(pCreateInfo->imageType));
1141 }
1142 if (pCreateInfo->mipLevels != 1) {
1143 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1144 pCreateInfo->mipLevels);
1145 }
1146 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1147 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1148 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1149 }
1150 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1151 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1152 base_message, string_VkImageTiling(pCreateInfo->tiling));
1153 }
1154 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1155 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1156 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1157 }
1158 const VkImageCreateFlags valid_flags =
1159 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001160 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001161 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001162 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001163 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001164 }
1165 }
1166 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001167
1168 // If Chroma subsampled format ( _420_ or _422_ )
1169 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1170 skip |=
1171 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1172 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1173 ") must be a multiple of 2.",
1174 string_VkFormat(image_format), pCreateInfo->extent.width);
1175 }
1176 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1177 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1178 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1179 ") must be a multiple of 2.",
1180 string_VkFormat(image_format), pCreateInfo->extent.height);
1181 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001182
1183 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1184 if (format_list_info) {
1185 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1186 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1187 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1188 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
1189 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1.",
1190 viewFormatCount);
1191 }
1192 // Check if viewFormatCount is not zero that it is all compatible
1193 for (uint32_t i = 0; i < viewFormatCount; i++) {
1194 if (FormatCompatibilityClass(format_list_info->pViewFormats[i]) != FormatCompatibilityClass(image_format)) {
1195 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-04737",
1196 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%u] (%s) and "
1197 "VkImageCreateInfo::format (%s) are not compatible.",
1198 i, string_VkFormat(format_list_info->pViewFormats[0]), string_VkFormat(image_format));
1199 }
1200 }
1201 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001202 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001203
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001204 return skip;
1205}
1206
Jeff Bolz99e3f632020-03-24 22:59:22 -05001207bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1208 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1209 bool skip = false;
1210
1211 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001212 // Validate feature set if using CUBE_ARRAY
1213 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1214 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1215 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1216 "enabling the imageCubeArray feature.");
1217 }
1218
Jeff Bolz99e3f632020-03-24 22:59:22 -05001219 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1220 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1221 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001222 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001223 pCreateInfo->subresourceRange.layerCount);
1224 }
1225 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001226 skip |= LogError(
1227 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1228 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1229 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001230 }
1231 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001232
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001233 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001234 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1235 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1236 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1237 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1238 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1239 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1240 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1241 }
1242 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1243 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1244 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1245 "not an ASTC format.",
1246 string_VkFormat(pCreateInfo->format));
1247 }
1248 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001249
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001250 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001251 if (ycbcr_conversion != nullptr) {
1252 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1253 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1254 skip |= LogError(
1255 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1256 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1257 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1258 "r swizzle = %s\n"
1259 "g swizzle = %s\n"
1260 "b swizzle = %s\n"
1261 "a swizzle = %s\n",
1262 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1263 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1264 }
1265 }
1266 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001267 }
1268 return skip;
1269}
1270
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001271bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001272 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001273 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001274
1275 // Note: for numerical correctness
1276 // - float comparisons should expect NaN (comparison always false).
1277 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1278
1279 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001280 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001281 if (v1_f <= 0.0f) return true;
1282
1283 float intpart;
1284 const float fract = modff(v1_f, &intpart);
1285
1286 assert(std::numeric_limits<float>::radix == 2);
1287 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1288 if (intpart >= u32_max_plus1) return false;
1289
1290 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001291 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001292 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001293 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001294 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001295 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001296 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001297 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001298 };
1299
1300 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1301 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1302 return (v1_f <= v2_f);
1303 };
1304
1305 // width
1306 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001307 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001308
1309 if (!(viewport.width > 0.0f)) {
1310 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001311 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1312 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001313 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1314 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001315 skip |= LogError(object, "VUID-VkViewport-width-01771",
1316 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1317 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001318 }
1319
1320 // height
1321 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001322 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001323 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001324
1325 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1326 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001327 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1328 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001329 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1330 height_healthy = false;
1331
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001332 skip |= LogError(object, "VUID-VkViewport-height-01773",
1333 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1334 ").",
1335 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001336 }
1337
1338 // x
1339 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001340 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001341 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001342 skip |= LogError(object, "VUID-VkViewport-x-01774",
1343 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1344 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001345 }
1346
1347 // x + width
1348 if (x_healthy && width_healthy) {
1349 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001350 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001351 skip |= LogError(
1352 object, "VUID-VkViewport-x-01232",
1353 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1354 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1355 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001356 }
1357 }
1358
1359 // y
1360 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001361 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001362 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001363 skip |= LogError(object, "VUID-VkViewport-y-01775",
1364 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1365 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001366 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001367 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001368 skip |= LogError(object, "VUID-VkViewport-y-01776",
1369 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1370 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001371 }
1372
1373 // y + height
1374 if (y_healthy && height_healthy) {
1375 const float boundary = viewport.y + viewport.height;
1376
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001377 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001378 skip |= LogError(object, "VUID-VkViewport-y-01233",
1379 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1380 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1381 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001382 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001383 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001384 LogError(object, "VUID-VkViewport-y-01777",
1385 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1386 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1387 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001388 }
1389 }
1390
sfricke-samsungfd06d422021-01-22 02:17:21 -08001391 // 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 -07001392 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001393 // minDepth
1394 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001395 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001396 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001397 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1398 "[0.0, 1.0] range.",
1399 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001400 }
1401
1402 // maxDepth
1403 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001404 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001405 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001406 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1407 "[0.0, 1.0] range.",
1408 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001409 }
1410 }
1411
1412 return skip;
1413}
1414
Dave Houlton142c4cb2018-10-17 15:04:41 -06001415struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001416 VkShadingRatePaletteEntryNV shadingRate;
1417 uint32_t width;
1418 uint32_t height;
1419};
1420
1421// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001422static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001423 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1424 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1425 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1426 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1427 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1428 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001429};
1430
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001431bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001432 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001433
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001434 SampleOrderInfo *sample_order_info;
1435 uint32_t info_idx = 0;
1436 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1437 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1438 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001439 break;
1440 }
1441 }
1442
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001443 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001444 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1445 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1446 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001447 return skip;
1448 }
1449
Dave Houlton142c4cb2018-10-17 15:04:41 -06001450 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001451 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001452 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1453 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1454 ") must "
1455 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1456 "is set in framebufferNoAttachmentsSampleCounts.",
1457 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001458 }
1459
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001460 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001461 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1462 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1463 ") must "
1464 "be equal to the product of sampleCount (=%" PRIu32
1465 "), the fragment width for shadingRate "
1466 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001467 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001468 }
1469
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001470 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001471 skip |= LogError(
1472 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001473 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1474 ") must "
1475 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001476 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001477 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001478
1479 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001480 // the first width*height*sampleCount bits to all be set. Note: There is no
1481 // guarantee that 64 bits is enough, but practically it's unlikely for an
1482 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001483 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001484 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001485 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001486 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1487 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001488 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1489 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001490 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001491 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001492 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1493 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001494 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001495 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001496 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1497 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001498 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001499 uint32_t idx =
1500 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1501 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001502 }
1503
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001504 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1505 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001506 skip |= LogError(
1507 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001508 "The array pSampleLocations must contain exactly one entry for "
1509 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001510 }
1511
1512 return skip;
1513}
1514
sfricke-samsung51303fb2021-05-09 19:09:13 -07001515bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1516 const VkAllocationCallbacks *pAllocator,
1517 VkPipelineLayout *pPipelineLayout) const {
1518 bool skip = false;
1519 // Validate layout count against device physical limit
1520 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1521 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
1522 "vkCreatePipelineLayout(): setLayoutCount (%d) exceeds physical device maxBoundDescriptorSets limit (%d).",
1523 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1524 }
1525
1526 // Validate Push Constant ranges
1527 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1528 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1529 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1530 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1531 // Check that offset + size don't exceed the max.
1532 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1533 if (offset >= max_push_constants_size) {
1534 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
1535 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) that exceeds this "
1536 "device's maxPushConstantSize of %u.",
1537 i, offset, max_push_constants_size);
1538 }
1539 if (size > max_push_constants_size - offset) {
1540 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
1541 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u] offset (%u) and size (%u) "
1542 "together exceeds this device's maxPushConstantSize of %u.",
1543 i, offset, size, max_push_constants_size);
1544 }
1545
1546 // size needs to be non-zero and a multiple of 4.
1547 if (size == 0) {
1548 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
1549 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not greater than zero.",
1550 i, size);
1551 }
1552 if (size & 0x3) {
1553 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
1554 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].size (%u) is not a multiple of 4.", i,
1555 size);
1556 }
1557
1558 // offset needs to be a multiple of 4.
1559 if ((offset & 0x3) != 0) {
1560 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
1561 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%u].offset (%u) is not a multiple of 4.",
1562 i, offset);
1563 }
1564 }
1565
1566 // 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.
1567 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1568 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1569 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
1570 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1571 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %d and %d.", i, j);
1572 }
1573 }
1574 }
1575 return skip;
1576}
1577
ziga-lunargc6341372021-07-28 12:57:42 +02001578bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1579 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1580 bool skip = false;
1581
1582 const auto *required_subgroup_size_features =
1583 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1584
1585 if (required_subgroup_size_features) {
1586 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1587 skip |= LogError(
1588 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1589 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1590 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1591 func_name, msg, pCreateInfo->flags);
1592 }
1593 }
1594
1595 return skip;
1596}
1597
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001598bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1599 uint32_t createInfoCount,
1600 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1601 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001602 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001603 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001604
1605 if (pCreateInfos != nullptr) {
1606 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001607 bool has_dynamic_viewport = false;
1608 bool has_dynamic_scissor = false;
1609 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001610 bool has_dynamic_depth_bias = false;
1611 bool has_dynamic_blend_constant = false;
1612 bool has_dynamic_depth_bounds = false;
1613 bool has_dynamic_stencil_compare = false;
1614 bool has_dynamic_stencil_write = false;
1615 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001616 bool has_dynamic_viewport_w_scaling_nv = false;
1617 bool has_dynamic_discard_rectangle_ext = false;
1618 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001619 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001620 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001621 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001622 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001623 bool has_dynamic_cull_mode = false;
1624 bool has_dynamic_front_face = false;
1625 bool has_dynamic_primitive_topology = false;
1626 bool has_dynamic_viewport_with_count = false;
1627 bool has_dynamic_scissor_with_count = false;
1628 bool has_dynamic_vertex_input_binding_stride = false;
1629 bool has_dynamic_depth_test_enable = false;
1630 bool has_dynamic_depth_write_enable = false;
1631 bool has_dynamic_depth_compare_op = false;
1632 bool has_dynamic_depth_bounds_test_enable = false;
1633 bool has_dynamic_stencil_test_enable = false;
1634 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001635 bool has_patch_control_points = false;
1636 bool has_rasterizer_discard_enable = false;
1637 bool has_depth_bias_enable = false;
1638 bool has_logic_op = false;
1639 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001640 bool has_dynamic_vertex_input = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001641 if (pCreateInfos[i].pDynamicState != nullptr) {
1642 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1643 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1644 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001645 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1646 if (has_dynamic_viewport == true) {
1647 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1648 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1649 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1650 i);
1651 }
1652 has_dynamic_viewport = true;
1653 }
1654 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1655 if (has_dynamic_scissor == true) {
1656 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1657 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1658 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1659 i);
1660 }
1661 has_dynamic_scissor = true;
1662 }
1663 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1664 if (has_dynamic_line_width == true) {
1665 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1666 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1667 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1668 i);
1669 }
1670 has_dynamic_line_width = true;
1671 }
1672 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1673 if (has_dynamic_depth_bias == true) {
1674 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1675 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1676 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1677 i);
1678 }
1679 has_dynamic_depth_bias = true;
1680 }
1681 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1682 if (has_dynamic_blend_constant == true) {
1683 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1684 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1685 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1686 i);
1687 }
1688 has_dynamic_blend_constant = true;
1689 }
1690 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1691 if (has_dynamic_depth_bounds == true) {
1692 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1693 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1694 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1695 i);
1696 }
1697 has_dynamic_depth_bounds = true;
1698 }
1699 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1700 if (has_dynamic_stencil_compare == true) {
1701 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1702 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1703 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1704 i);
1705 }
1706 has_dynamic_stencil_compare = true;
1707 }
1708 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1709 if (has_dynamic_stencil_write == true) {
1710 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1711 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1712 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1713 i);
1714 }
1715 has_dynamic_stencil_write = true;
1716 }
1717 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1718 if (has_dynamic_stencil_reference == true) {
1719 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1720 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1721 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1722 i);
1723 }
1724 has_dynamic_stencil_reference = true;
1725 }
1726 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1727 if (has_dynamic_viewport_w_scaling_nv == true) {
1728 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1729 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1730 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1731 i);
1732 }
1733 has_dynamic_viewport_w_scaling_nv = true;
1734 }
1735 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1736 if (has_dynamic_discard_rectangle_ext == true) {
1737 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1738 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1739 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1740 i);
1741 }
1742 has_dynamic_discard_rectangle_ext = true;
1743 }
1744 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1745 if (has_dynamic_sample_locations_ext == true) {
1746 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1747 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1748 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1749 i);
1750 }
1751 has_dynamic_sample_locations_ext = true;
1752 }
1753 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1754 if (has_dynamic_exclusive_scissor_nv == true) {
1755 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1756 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1757 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1758 i);
1759 }
1760 has_dynamic_exclusive_scissor_nv = true;
1761 }
1762 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1763 if (has_dynamic_shading_rate_palette_nv == true) {
1764 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1765 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1766 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1767 i);
1768 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001769 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001770 }
1771 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1772 if (has_dynamic_viewport_course_sample_order_nv == true) {
1773 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1774 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1775 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1776 i);
1777 }
1778 has_dynamic_viewport_course_sample_order_nv = true;
1779 }
1780 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1781 if (has_dynamic_line_stipple == true) {
1782 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1783 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1784 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1785 i);
1786 }
1787 has_dynamic_line_stipple = true;
1788 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001789 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1790 if (has_dynamic_cull_mode) {
1791 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1792 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1793 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1794 i);
1795 }
1796 has_dynamic_cull_mode = true;
1797 }
1798 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1799 if (has_dynamic_front_face) {
1800 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1801 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1802 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1803 i);
1804 }
1805 has_dynamic_front_face = true;
1806 }
1807 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1808 if (has_dynamic_primitive_topology) {
1809 skip |= LogError(
1810 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1811 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1812 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1813 i);
1814 }
1815 has_dynamic_primitive_topology = true;
1816 }
1817 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1818 if (has_dynamic_viewport_with_count) {
1819 skip |= LogError(
1820 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1821 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1822 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1823 i);
1824 }
1825 has_dynamic_viewport_with_count = true;
1826 }
1827 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1828 if (has_dynamic_scissor_with_count) {
1829 skip |= LogError(
1830 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1831 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1832 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1833 i);
1834 }
1835 has_dynamic_scissor_with_count = true;
1836 }
1837 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1838 if (has_dynamic_vertex_input_binding_stride) {
1839 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1840 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1841 "listed twice in the "
1842 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1843 i);
1844 }
1845 has_dynamic_vertex_input_binding_stride = true;
1846 }
1847 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1848 if (has_dynamic_depth_test_enable) {
1849 skip |= LogError(
1850 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1851 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1852 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1853 i);
1854 }
1855 has_dynamic_depth_test_enable = true;
1856 }
1857 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1858 if (has_dynamic_depth_write_enable) {
1859 skip |= LogError(
1860 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1861 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1862 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1863 i);
1864 }
1865 has_dynamic_depth_write_enable = true;
1866 }
1867 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1868 if (has_dynamic_depth_compare_op) {
1869 skip |=
1870 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1871 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1872 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1873 i);
1874 }
1875 has_dynamic_depth_compare_op = true;
1876 }
1877 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1878 if (has_dynamic_depth_bounds_test_enable) {
1879 skip |= LogError(
1880 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1881 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1882 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1883 i);
1884 }
1885 has_dynamic_depth_bounds_test_enable = true;
1886 }
1887 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1888 if (has_dynamic_stencil_test_enable) {
1889 skip |= LogError(
1890 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1891 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1892 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1893 i);
1894 }
1895 has_dynamic_stencil_test_enable = true;
1896 }
1897 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1898 if (has_dynamic_stencil_op) {
1899 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1900 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1901 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1902 i);
1903 }
1904 has_dynamic_stencil_op = true;
1905 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001906 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
1907 // Not allowed for graphics pipelines
1908 skip |= LogError(
1909 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
1910 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
1911 "pCreateInfos[%d].pDynamicState->pDynamicStates[%d] but not allowed in graphic pipelines.",
1912 i, state_index);
1913 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001914 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
1915 if (has_patch_control_points) {
1916 skip |= LogError(
1917 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1918 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
1919 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1920 i);
1921 }
1922 has_patch_control_points = true;
1923 }
1924 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
1925 if (has_rasterizer_discard_enable) {
1926 skip |= LogError(
1927 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1928 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
1929 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1930 i);
1931 }
1932 has_rasterizer_discard_enable = true;
1933 }
1934 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
1935 if (has_depth_bias_enable) {
1936 skip |= LogError(
1937 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1938 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
1939 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1940 i);
1941 }
1942 has_depth_bias_enable = true;
1943 }
1944 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
1945 if (has_logic_op) {
1946 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1947 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
1948 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1949 i);
1950 }
1951 has_logic_op = true;
1952 }
1953 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
1954 if (has_primitive_restart_enable) {
1955 skip |= LogError(
1956 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1957 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
1958 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1959 i);
1960 }
1961 has_primitive_restart_enable = true;
1962 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06001963 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
1964 if (has_dynamic_vertex_input) {
1965 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1966 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
1967 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1968 i);
1969 }
1970 has_dynamic_vertex_input = true;
1971 }
Petr Kraus299ba622017-11-24 03:09:03 +01001972 }
1973 }
1974
sfricke-samsung3b944422021-01-23 02:15:19 -08001975 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
1976 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
1977 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
1978 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1979 i);
1980 }
1981
1982 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
1983 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
1984 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
1985 "both listed in pCreateInfos[%d].pDynamicState->pDynamicStates array",
1986 i);
1987 }
1988
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001989 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04001990 if ((feedback_struct != nullptr) &&
1991 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001992 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1993 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1994 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1995 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1996 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001997 }
1998
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001999 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002000
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002001 // Collect active stages and other information
2002 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002003 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002004 bool has_eval = false;
2005 bool has_control = false;
2006 if (pCreateInfos[i].pStages != nullptr) {
2007 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
2008 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
2009
2010 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
2011 has_control = true;
2012 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
2013 has_eval = true;
2014 }
2015
2016 skip |= validate_string(
2017 "vkCreateGraphicsPipelines",
2018 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2019 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
ziga-lunargc6341372021-07-28 12:57:42 +02002020
2021 std::stringstream msg;
2022 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2023 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
2024 &pCreateInfos[i].pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002025 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002026 }
2027
2028 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
2029 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
2030 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2031 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2032 pCreateInfos[i].pTessellationState,
2033 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
2034 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
2035
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002036 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002037 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2038
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002039 skip |= validate_struct_pnext(
2040 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
2041 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
2042 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2043 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2044 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2045 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002046
2047 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
2048 pCreateInfos[i].pTessellationState->flags,
2049 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2050 }
2051
2052 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
2053 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2054 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
2055 pCreateInfos[i].pInputAssemblyState,
2056 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2057 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2058
2059 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
2060 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002061 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002062
2063 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
2064 pCreateInfos[i].pInputAssemblyState->flags,
2065 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2066
2067 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2068 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
2069 pCreateInfos[i].pInputAssemblyState->topology,
2070 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2071
2072 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
2073 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
2074 }
2075
2076 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002077 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002078
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002079 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002080 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2081 "vkCreateGraphicsPipelines: pararameter "
2082 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
2083 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002084 }
2085
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002086 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002087 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
2088 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2089 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
2090 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002091 allowed_structs_vk_pipeline_vertex_input_state_create_info,
2092 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002093 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002094 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2095 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002096 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002097 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2098 skip |=
2099 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2100 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
2101 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
2102 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
2103 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2104
2105 skip |= validate_array(
2106 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2107 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2108 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2109 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2110
2111 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002112 for (uint32_t vertex_binding_description_index = 0;
2113 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
2114 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002115 skip |= validate_ranged_enum(
2116 "vkCreateGraphicsPipelines",
2117 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2118 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002119 pCreateInfos[i]
2120 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
2121 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002122 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2123 }
2124 }
2125
2126 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002127 for (uint32_t vertex_attribute_description_index = 0;
2128 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
2129 ++vertex_attribute_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002130 skip |= validate_ranged_enum(
2131 "vkCreateGraphicsPipelines",
2132 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2133 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002134 pCreateInfos[i]
2135 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2136 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002137 "VUID-VkVertexInputAttributeDescription-format-parameter");
2138 }
2139 }
2140
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002141 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002142 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2143 "vkCreateGraphicsPipelines: pararameter "
2144 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
2145 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2146 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002147 }
2148
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002149 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002150 skip |=
2151 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2152 "vkCreateGraphicsPipelines: pararameter "
2153 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
2154 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2155 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002156 }
2157
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002158 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002159 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2160 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002161 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2162 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002163 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2164 "vkCreateGraphicsPipelines: parameter "
2165 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
2166 "(%" PRIu32 ") is not distinct.",
2167 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002168 }
2169 vertex_bindings.insert(vertex_bind_desc.binding);
2170
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002171 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002172 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2173 "vkCreateGraphicsPipelines: parameter "
2174 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
2175 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2176 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002177 }
2178
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002179 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002180 skip |=
2181 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2182 "vkCreateGraphicsPipelines: parameter "
2183 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
2184 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
2185 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002186 }
2187 }
2188
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002189 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002190 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2191 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002192 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2193 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002194 skip |= LogError(
2195 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002196 "vkCreateGraphicsPipelines: parameter "
2197 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
2198 i, d, vertex_attrib_desc.location);
2199 }
2200 attribute_locations.insert(vertex_attrib_desc.location);
2201
2202 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2203 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002204 skip |= LogError(
2205 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02002206 "vkCreateGraphicsPipelines: parameter "
2207 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
2208 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
2209 i, d, vertex_attrib_desc.binding, i);
2210 }
2211
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002212 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002213 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2214 "vkCreateGraphicsPipelines: parameter "
2215 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
2216 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
2217 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002218 }
2219
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002220 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002221 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2222 "vkCreateGraphicsPipelines: parameter "
2223 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
2224 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
2225 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002226 }
2227
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002228 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002229 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2230 "vkCreateGraphicsPipelines: parameter "
2231 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
2232 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
2233 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002234 }
2235 }
2236 }
2237
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002238 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2239 if (has_control && has_eval) {
2240 if (pCreateInfos[i].pTessellationState == nullptr) {
2241 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
2242 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
2243 "shader stage and a tessellation evaluation shader stage, "
2244 "pCreateInfos[%d].pTessellationState must not be NULL.",
2245 i, i);
2246 } else {
2247 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2248 skip |= validate_struct_pnext(
2249 "vkCreateGraphicsPipelines",
2250 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2251 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2252 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2253 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002254
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002255 skip |= validate_reserved_flags(
2256 "vkCreateGraphicsPipelines",
2257 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2258 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002259
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002260 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2261 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2262 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2263 "vkCreateGraphicsPipelines: invalid parameter "
2264 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
2265 "should be >0 and <=%u.",
2266 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2267 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002268 }
2269 }
2270 }
2271
2272 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2273 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2274 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2275 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002276 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2277 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2278 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2279 "].pViewportState (=NULL) is not a valid pointer.",
2280 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002281 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002282 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2283
2284 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002285 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2286 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2287 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2288 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002289 }
2290
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002291 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002292 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002293 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2294 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002295 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2296 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002297 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002298 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002299 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002300 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002301 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002302 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2303 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002304 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2305 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2306 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002307 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002308
2309 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002310 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002311 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002312 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002313
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002314 auto exclusive_scissor_struct =
2315 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2316 auto shading_rate_image_struct =
2317 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2318 auto coarse_sample_order_struct =
2319 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002320 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002321 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002322 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002323 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002324
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002325 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002326 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002327 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2328 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2329 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2330 ") is not 1.",
2331 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002332 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002333
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002334 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002335 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2336 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2337 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2338 ") is not 1.",
2339 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002340 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002341
Dave Houlton142c4cb2018-10-17 15:04:41 -06002342 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2343 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002344 skip |= LogError(
2345 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2346 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2347 "disabled, but pCreateInfos[%" PRIu32
2348 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2349 ") is not 1.",
2350 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002351 }
2352
Jeff Bolz9af91c52018-09-01 21:53:57 -05002353 if (shading_rate_image_struct &&
2354 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002355 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2356 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2357 "disabled, but pCreateInfos[%" PRIu32
2358 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2359 ") is neither 0 nor 1.",
2360 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002361 }
2362
Petr Krausa6103552017-11-16 21:21:58 +01002363 } else { // multiViewport enabled
2364 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002365 if (!has_dynamic_viewport_with_count) {
2366 skip |= LogError(
2367 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2368 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2369 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002370 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002371 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2372 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2373 "].pViewportState->viewportCount (=%" PRIu32
2374 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2375 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002376 } else if (has_dynamic_viewport_with_count) {
2377 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2378 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2379 "].pViewportState->viewportCount (=%" PRIu32
2380 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2381 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002382 }
Petr Krausa6103552017-11-16 21:21:58 +01002383
2384 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002385 if (!has_dynamic_scissor_with_count) {
2386 skip |= LogError(
2387 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2388 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2389 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002390 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002391 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2392 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2393 "].pViewportState->scissorCount (=%" PRIu32
2394 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2395 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002396 } else if (has_dynamic_scissor_with_count) {
2397 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2398 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2399 "].pViewportState->scissorCount (=%" PRIu32
2400 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2401 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002402 }
2403 }
2404
ziga-lunarg845883b2021-07-14 15:05:00 +02002405 if (!has_dynamic_scissor && viewport_state.pScissors) {
2406 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2407 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002408
2409 if (scissor.offset.x < 0) {
2410 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2411 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2412 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2413 scissor.offset.x, i, scissor_i);
2414 }
2415
2416 if (scissor.offset.y < 0) {
2417 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2418 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2419 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2420 scissor.offset.y, i, scissor_i);
2421 }
2422
ziga-lunarg845883b2021-07-14 15:05:00 +02002423 const int64_t x_sum =
2424 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2425 if (x_sum > std::numeric_limits<int32_t>::max()) {
2426 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2427 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2428 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2429 "] will overflow int32_t.",
2430 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2431 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002432
ziga-lunarg845883b2021-07-14 15:05:00 +02002433 const int64_t y_sum =
2434 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2435 if (y_sum > std::numeric_limits<int32_t>::max()) {
2436 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2437 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2438 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2439 "] will overflow int32_t.",
2440 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2441 }
2442 }
2443 }
2444
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002445 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002446 skip |=
2447 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2448 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2449 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2450 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002451 }
2452
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002453 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002454 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2455 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2456 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2457 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2458 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002459 }
2460
Piers Daniell39842ee2020-07-10 16:42:33 -06002461 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2462 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002463 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2464 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2465 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2466 "].pViewportState->viewportCount (=%" PRIu32 ").",
2467 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002468 }
2469
Dave Houlton142c4cb2018-10-17 15:04:41 -06002470 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002471 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002472 skip |=
2473 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2474 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2475 ") must be zero or identical to pCreateInfos[%" PRIu32
2476 "].pViewportState->viewportCount (=%" PRIu32 ").",
2477 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002478 }
2479
Dave Houlton142c4cb2018-10-17 15:04:41 -06002480 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002481 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002482 skip |= LogError(
2483 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002484 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2485 "] "
2486 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2487 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2488 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002489 }
2490
Petr Krausa6103552017-11-16 21:21:58 +01002491 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002492 skip |= LogError(
2493 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002494 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2495 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002496 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2497 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002498 }
2499
2500 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002501 skip |= LogError(
2502 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002503 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2504 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002505 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2506 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002507 }
2508
Jeff Bolz3e71f782018-08-29 23:15:45 -05002509 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002510 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2511 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2512 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002513 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002514 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2515 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2516 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2517 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002518 }
2519
Jeff Bolz9af91c52018-09-01 21:53:57 -05002520 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002521 shading_rate_image_struct->viewportCount > 0 &&
2522 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002523 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002524 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002525 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002526 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2527 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002528 i, i);
2529 }
2530
Chris Mayer328d8212018-12-11 14:16:18 +01002531 if (vp_swizzle_struct) {
2532 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002533 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2534 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2535 " does "
2536 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2537 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002538 }
2539 }
2540
Petr Krausb3fcdb42018-01-09 22:09:09 +01002541 // validate the VkViewports
2542 if (!has_dynamic_viewport && viewport_state.pViewports) {
2543 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2544 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002545 const char *fn_name = "vkCreateGraphicsPipelines";
2546 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2547 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2548 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002549 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002550 }
2551 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002552
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002553 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002554 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2555 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2556 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2557 "VK_NV_clip_space_w_scaling extension is not enabled.",
2558 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002559 }
2560
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002561 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002562 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2563 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2564 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2565 "VK_EXT_discard_rectangles extension is not enabled.",
2566 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002567 }
2568
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002569 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002570 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2571 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2572 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2573 "VK_EXT_sample_locations extension is not enabled.",
2574 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002575 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002576
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002577 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002578 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2579 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2580 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2581 "VK_NV_scissor_exclusive extension is not enabled.",
2582 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002583 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002584
2585 if (coarse_sample_order_struct &&
2586 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2587 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002588 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2589 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2590 "] "
2591 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2592 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2593 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002594 }
2595
2596 if (coarse_sample_order_struct) {
2597 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002598 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002599 }
2600 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002601
2602 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2603 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002604 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2605 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2606 "] "
2607 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2608 ") "
2609 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2610 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002611 }
2612 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002613 skip |= LogError(
2614 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002615 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2616 "] "
2617 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2618 i);
2619 }
2620 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002621 }
2622
2623 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002624 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2625 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2626 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2627 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002628 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002629 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002630 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002631 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2632 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002633 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002634 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002635 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002636 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002637 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002638 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002639 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002640 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2641 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002642
2643 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002644 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002645 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002646 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002647
2648 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002649 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002650 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2651 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2652
2653 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002654 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002655 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2656 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002657 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002658 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002659
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002660 skip |= validate_flags(
2661 "vkCreateGraphicsPipelines",
2662 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2663 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002664 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002665
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002666 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002667 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002668 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2669 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2670
2671 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002672 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002673 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2674 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2675
2676 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002677 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002678 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2679 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2680 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002681 }
John Zulauf7acac592017-11-06 11:15:53 -07002682 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002683 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002684 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2685 "vkCreateGraphicsPipelines(): parameter "
2686 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2687 i);
John Zulauf7acac592017-11-06 11:15:53 -07002688 }
2689 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2690 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2691 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002692 skip |= LogError(
2693 device,
2694
Dave Houlton413a6782018-05-22 13:01:54 -06002695 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002696 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002697 }
2698 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002699
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002700 const auto *line_state =
2701 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002702
2703 if (line_state) {
2704 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2705 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2706 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2707 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002708 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2709 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2710 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2711 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002712 }
2713 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2714 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002715 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2716 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2717 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2718 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002719 }
2720 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2721 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002722 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2723 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2724 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2725 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002726 }
2727 }
2728 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2729 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2730 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002731 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2732 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2733 "range [1,256].",
2734 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002735 }
2736 }
2737 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002738 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002739 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2740 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002741 skip |=
2742 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2743 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2744 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2745 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002746 }
2747 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2748 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002749 skip |=
2750 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2751 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2752 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2753 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002754 }
2755 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2756 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002757 skip |=
2758 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2759 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2760 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2761 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002762 }
2763 if (line_state->stippledLineEnable) {
2764 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2765 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002766 skip |=
2767 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2768 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2769 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2770 "stippledRectangularLines feature.",
2771 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002772 }
2773 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2774 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002775 skip |=
2776 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2777 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2778 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2779 "stippledBresenhamLines feature.",
2780 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002781 }
2782 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2783 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002784 skip |=
2785 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2786 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2787 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2788 "stippledSmoothLines feature.",
2789 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002790 }
2791 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2792 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002793 skip |=
2794 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2795 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2796 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2797 "stippledRectangularLines and strictLines features.",
2798 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002799 }
2800 }
2801 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002802 }
2803
Petr Krause91f7a12017-12-14 20:57:36 +01002804 bool uses_color_attachment = false;
2805 bool uses_depthstencil_attachment = false;
2806 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002807 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002808 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2809 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002810 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002811 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002812 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002813 }
2814 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002815 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002816 }
Petr Krause91f7a12017-12-14 20:57:36 +01002817 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002818 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002819 }
2820
2821 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002822 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002823 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002824 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002825 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002826 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002827
2828 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002829 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002830 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002831 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002832
2833 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002834 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002835 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2836 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2837
2838 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002839 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002840 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2841 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2842
2843 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002844 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002845 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2846 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002847 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002848
2849 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002850 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002851 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2852 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2853
2854 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002855 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002856 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2857 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2858
2859 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002860 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002861 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2862 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002863 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002864
2865 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002866 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002867 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2868 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002869 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002870
2871 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002872 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002873 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2874 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002875 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002876
2877 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002878 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002879 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2880 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002881 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002882
2883 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002884 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002885 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2886 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002887 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002888
2889 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002890 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002891 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2892 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002893 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002894
2895 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002896 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002897 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2898 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002899 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002900
2901 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002902 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002903 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2904 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002905 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002906
2907 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002908 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002909 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2910 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2911 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002912 }
2913 }
2914
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002915 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002916 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2917
Petr Krause91f7a12017-12-14 20:57:36 +01002918 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002919 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2920 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2921 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2922 pCreateInfos[i].pColorBlendState,
2923 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2924 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2925
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002926 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002927 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002928 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2929 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002930 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2931 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002932 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2933 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002934
2935 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002936 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002937 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002938 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002939
2940 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002941 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002942 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2943 pCreateInfos[i].pColorBlendState->logicOpEnable);
2944
2945 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002946 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002947 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2948 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002949 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002950 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002951
2952 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002953 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
2954 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002955 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002956 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002957 ParameterName::IndexVector{i, attachment_index}),
2958 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002959
2960 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002961 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002962 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002963 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002964 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002965 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002966 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002967
2968 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002969 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002970 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002971 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002972 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002973 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002974 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002975
2976 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002977 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002978 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002979 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002980 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002981 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002982 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002983
2984 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002985 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002986 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002987 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002988 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002989 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002990 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002991
2992 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002993 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002994 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002995 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002996 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002997 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002998 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002999
3000 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003001 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003002 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003003 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003004 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003005 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003006 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003007
3008 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003009 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003010 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003011 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003012 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003013 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003014 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003015
3016 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3017 bool invalid = false;
3018 switch (pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
3019 case VK_BLEND_OP_ZERO_EXT:
3020 case VK_BLEND_OP_SRC_EXT:
3021 case VK_BLEND_OP_DST_EXT:
3022 case VK_BLEND_OP_SRC_OVER_EXT:
3023 case VK_BLEND_OP_DST_OVER_EXT:
3024 case VK_BLEND_OP_SRC_IN_EXT:
3025 case VK_BLEND_OP_DST_IN_EXT:
3026 case VK_BLEND_OP_SRC_OUT_EXT:
3027 case VK_BLEND_OP_DST_OUT_EXT:
3028 case VK_BLEND_OP_SRC_ATOP_EXT:
3029 case VK_BLEND_OP_DST_ATOP_EXT:
3030 case VK_BLEND_OP_XOR_EXT:
3031 case VK_BLEND_OP_INVERT_EXT:
3032 case VK_BLEND_OP_INVERT_RGB_EXT:
3033 case VK_BLEND_OP_LINEARDODGE_EXT:
3034 case VK_BLEND_OP_LINEARBURN_EXT:
3035 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3036 case VK_BLEND_OP_LINEARLIGHT_EXT:
3037 case VK_BLEND_OP_PINLIGHT_EXT:
3038 case VK_BLEND_OP_HARDMIX_EXT:
3039 case VK_BLEND_OP_PLUS_EXT:
3040 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3041 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3042 case VK_BLEND_OP_PLUS_DARKER_EXT:
3043 case VK_BLEND_OP_MINUS_EXT:
3044 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3045 case VK_BLEND_OP_CONTRAST_EXT:
3046 case VK_BLEND_OP_INVERT_OVG_EXT:
3047 case VK_BLEND_OP_RED_EXT:
3048 case VK_BLEND_OP_GREEN_EXT:
3049 case VK_BLEND_OP_BLUE_EXT:
3050 invalid = true;
3051 break;
3052 default:
3053 break;
3054 }
3055 if (invalid) {
3056 skip |= LogError(
3057 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3058 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3059 "].pColorBlendState->pAttachments[%" PRIu32
3060 "].colorBlendOp (%s) is not valid when "
3061 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3062 "VK_FALSE",
3063 i, attachment_index,
3064 string_VkBlendOp(
3065 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp));
3066 }
3067 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003068 }
3069 }
3070
3071 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003072 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003073 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
3074 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3075 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003076 }
3077
3078 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
3079 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
3080 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003081 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003082 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06003083 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
3084 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003085 }
3086 }
3087 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003088
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003089 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3090 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01003091 if (pCreateInfos[i].basePipelineIndex != -1) {
3092 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003093 skip |=
3094 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003095 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003096 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003097 "and pCreateInfos->basePipelineIndex is not -1.",
3098 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003099 }
3100 }
3101
Petr Kraus9752aae2017-11-24 03:05:50 +01003102 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3103 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003104 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003105 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003106 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003107 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3108 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003109 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003110 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07003111 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003112 skip |=
3113 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
3114 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
3115 "index into the pCreateInfos array, of size %d.",
3116 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003117 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003118 }
3119 }
3120
Petr Kraus9752aae2017-11-24 03:05:50 +01003121 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003122 if (!device_extensions.vk_nv_fill_rectangle) {
3123 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
3124 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003125 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3126 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3127 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3128 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02003129 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3130 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003131 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003132 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003133 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
3134 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3135 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003136 }
3137 } else {
3138 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3139 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
3140 (physical_device_features.fillModeNonSolid == false)) {
3141 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003142 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3143 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003144 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
3145 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3146 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003147 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003148 }
Petr Kraus299ba622017-11-24 03:09:03 +01003149
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003150 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01003151 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003152 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3153 "The line width state is static (pCreateInfos[%" PRIu32
3154 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3155 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3156 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
3157 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003158 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003159 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003160
3161 // Validate no flags not allowed are used
3162 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003163 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
3164 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3165 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3166 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003167 }
3168 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003169 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
3170 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3171 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3172 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003173 }
3174 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3175 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsungad008902021-04-16 01:25:34 -07003176 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3177 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3178 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003179 }
3180 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3181 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsungad008902021-04-16 01:25:34 -07003182 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3183 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3184 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003185 }
3186 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3187 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsungad008902021-04-16 01:25:34 -07003188 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3189 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3190 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003191 }
3192 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3193 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsungad008902021-04-16 01:25:34 -07003194 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3195 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3196 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003197 }
3198 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3199 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsungad008902021-04-16 01:25:34 -07003200 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3201 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3202 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003203 }
3204 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3205 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsungad008902021-04-16 01:25:34 -07003206 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3207 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3208 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003209 }
3210 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3211 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsungad008902021-04-16 01:25:34 -07003212 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3213 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3214 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003215 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003216 }
3217 }
3218
3219 return skip;
3220}
3221
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003222bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3223 uint32_t createInfoCount,
3224 const VkComputePipelineCreateInfo *pCreateInfos,
3225 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003226 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003227 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003228 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003229 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003230 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003231 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003232 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003233 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003234 skip |=
3235 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
3236 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3237 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3238 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003239 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003240
3241 // Make sure compute stage is selected
3242 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003243 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
3244 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
3245 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003246 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003247
sfricke-samsungeb549012021-04-16 01:25:51 -07003248 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3249 // Validate no flags not allowed are used
3250 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
3251 skip |= LogError(
3252 device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3253 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3254 i, flags);
3255 }
3256 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3257 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
3258 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3259 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3260 i, flags);
3261 }
3262 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3263 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
3264 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3265 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3266 i, flags);
3267 }
3268 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3269 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
3270 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3271 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3272 i, flags);
3273 }
3274 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3275 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
3276 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3277 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3278 i, flags);
3279 }
3280 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3281 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
3282 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3283 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3284 i, flags);
3285 }
3286 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3287 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
3288 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3289 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3290 i, flags);
3291 }
3292 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3293 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
3294 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3295 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3296 i, flags);
3297 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003298 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3299 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
3300 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3301 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3302 i, flags);
3303 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003304 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3305 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
3306 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3307 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3308 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003309 }
ziga-lunargc6341372021-07-28 12:57:42 +02003310
3311 std::stringstream msg;
3312 msg << "pCreateInfos[%" << i << "].stage";
3313 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003314 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003315 return skip;
3316}
3317
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003318bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003319 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003320 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003321
3322 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003323 const auto &features = physical_device_features;
3324 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003325
John Zulauf71968502017-10-26 13:51:15 -06003326 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3327 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003328 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3329 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3330 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3331 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003332 }
3333
3334 // Anistropy cannot be enabled in sampler unless enabled as a feature
3335 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003336 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3337 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3338 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003339 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003340 }
John Zulauf71968502017-10-26 13:51:15 -06003341
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003342 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3343 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003344 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3345 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3346 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3347 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003348 }
3349 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003350 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3351 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3352 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3353 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003354 }
3355 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003356 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3357 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3358 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3359 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003360 }
3361 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3362 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3363 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3364 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003365 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3366 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3367 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3368 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3369 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3370 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003371 }
3372 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003373 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3374 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3375 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003376 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003377 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003378 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3379 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3380 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003381 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003382 }
3383
3384 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3385 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003386 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3387 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003388 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003389 if (sampler_reduction != nullptr) {
3390 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3391 skip |= LogError(
3392 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3393 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3394 }
3395 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003396 }
3397
3398 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3399 // valid VkBorderColor value
3400 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3401 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3402 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003403 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3404 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003405 }
3406
John Zulauf275805c2017-10-26 15:34:49 -06003407 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003408 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06003409 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3410 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003411 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3412 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3413 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003414 }
3415 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003416
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003417 // Check for valid Lod range
3418 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003419 skip |=
3420 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3421 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003422 }
3423
3424 // Check mipLodBias to device limit
3425 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003426 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3427 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3428 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003429 }
3430
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003431 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003432 if (sampler_conversion != nullptr) {
3433 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3434 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3435 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3436 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003437 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003438 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003439 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3440 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3441 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3442 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3443 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3444 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3445 }
3446 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003447
3448 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3449 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3450 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3451 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3452 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3453 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3454 }
3455 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3456 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3457 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3458 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3459 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3460 }
3461 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3462 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3463 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3464 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3465 pCreateInfo->minLod, pCreateInfo->maxLod);
3466 }
3467 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3468 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3469 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3470 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3471 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3472 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3473 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3474 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3475 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3476 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3477 }
3478 if (pCreateInfo->anisotropyEnable) {
3479 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3480 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3481 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3482 }
3483 if (pCreateInfo->compareEnable) {
3484 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3485 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3486 "pCreateInfo->compareEnable must be VK_FALSE");
3487 }
3488 if (pCreateInfo->unnormalizedCoordinates) {
3489 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3490 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3491 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3492 }
3493 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003494 }
3495
Tony-LunarG7337b312020-04-15 16:40:25 -06003496 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3497 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3498 if (!device_extensions.vk_ext_custom_border_color) {
3499 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3500 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3501 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3502 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003503 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003504 if (!custom_create_info) {
3505 skip |=
3506 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3507 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3508 "struct in pNext chain.\n",
3509 string_VkBorderColor(pCreateInfo->borderColor));
3510 } else {
3511 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3512 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3513 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3514 !FormatIsSampledFloat(custom_create_info->format)))) {
3515 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3516 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3517 "whose type does not match\n",
3518 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3519 ;
3520 }
3521 }
3522 }
3523
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003524 return skip;
3525}
3526
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003527bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3528 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3529 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003530 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003531 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003532
3533 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3534 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3535 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3536 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003537 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3538 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3539 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3540 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3541 ++descriptor_index) {
3542 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003543 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003544 "vkCreateDescriptorSetLayout: required parameter "
3545 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3546 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003547 }
3548 }
3549 }
3550
3551 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3552 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3553 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003554 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3555 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3556 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3557 "values.",
3558 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003559 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003560
3561 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3562 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3563 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3564 skip |=
3565 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3566 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3567 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3568 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3569 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3570 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003571 }
3572 }
3573 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003574 return skip;
3575}
3576
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003577bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3578 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003579 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003580 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3581 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3582 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003583 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3584 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003585}
3586
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003587bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3588 const VkWriteDescriptorSet *pDescriptorWrites,
3589 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003590 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003591
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003592 if (pDescriptorWrites != NULL) {
3593 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3594 // descriptorCount must be greater than 0
3595 if (pDescriptorWrites[i].descriptorCount == 0) {
3596 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003597 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3598 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003599 }
3600
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003601 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3602 if (validateDstSet) {
3603 // dstSet must be a valid VkDescriptorSet handle
3604 skip |= validate_required_handle(vkCallingFunction,
3605 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3606 pDescriptorWrites[i].dstSet);
3607 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003608
3609 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3610 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3611 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3612 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3613 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3614 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3615 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003616 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3617 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003618 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003619 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3620 "%s(): if pDescriptorWrites[%d].descriptorType is "
3621 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3622 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3623 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3624 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003625 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3626 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003627 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3628 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003629 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3630 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003631 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003632 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3633 ParameterName::IndexVector{i, descriptor_index}),
3634 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003635 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003636 }
3637 }
3638 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3639 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3640 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3641 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3642 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3643 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3644 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003645 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003646 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003647 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3648 "%s(): if pDescriptorWrites[%d].descriptorType is "
3649 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3650 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3651 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3652 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003653 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003654 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003655 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003656 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003657 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3658 ++descriptor_index) {
3659 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3660 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3661 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003662 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3663 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003664 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003665 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3666 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003667 }
3668 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003669 }
3670 }
3671 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3672 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003673 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003674 }
3675
3676 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3677 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003678 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003679 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3680 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003681 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003682 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003683 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3684 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3685 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003686 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003687 }
3688 }
3689 }
3690 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3691 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003692 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003693 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3694 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003695 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003696 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003697 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3698 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3699 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003700 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003701 }
3702 }
3703 }
3704 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003705 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3706 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003707 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003708 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003709 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3710 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3711 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3712 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3713 "accelerationStructureCount %d member equals descriptorCount %d.",
3714 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3715 pDescriptorWrites[i].descriptorCount);
3716 }
3717 // further checks only if we have right structtype
3718 if (pnext_struct) {
3719 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3720 skip |= LogError(
3721 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3722 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3723 ".",
3724 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003725 }
sourav parmarbcee7512020-12-28 14:34:49 -08003726 if (pnext_struct->accelerationStructureCount == 0) {
3727 skip |= LogError(device,
3728 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003729 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003730 }
3731 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003732 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003733 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3734 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3735 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3736 skip |= LogError(device,
3737 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3738 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003739 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003740 }
3741 }
3742 }
sourav parmarbcee7512020-12-28 14:34:49 -08003743 }
3744 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003745 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003746 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3747 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3748 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3749 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3750 "accelerationStructureCount %d member equals descriptorCount %d.",
3751 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3752 pDescriptorWrites[i].descriptorCount);
3753 }
3754 // further checks only if we have right structtype
3755 if (pnext_struct) {
3756 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3757 skip |= LogError(
3758 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3759 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3760 ".",
3761 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003762 }
sourav parmarbcee7512020-12-28 14:34:49 -08003763 if (pnext_struct->accelerationStructureCount == 0) {
3764 skip |= LogError(device,
3765 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003766 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003767 }
3768 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003769 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003770 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3771 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3772 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3773 skip |= LogError(device,
3774 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3775 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003776 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003777 }
3778 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003779 }
3780 }
3781 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003782 }
3783 }
3784 return skip;
3785}
3786
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003787bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3788 const VkWriteDescriptorSet *pDescriptorWrites,
3789 uint32_t descriptorCopyCount,
3790 const VkCopyDescriptorSet *pDescriptorCopies) const {
3791 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3792}
3793
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003794bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003795 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003796 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003797 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3798}
3799
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003800bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3801 const VkAllocationCallbacks *pAllocator,
3802 VkRenderPass *pRenderPass) const {
3803 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3804}
3805
Mike Schuchardt2df08912020-12-15 16:28:09 -08003806bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003807 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003808 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003809 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3810}
3811
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003812bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3813 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003814 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003815 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003816
3817 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3818 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3819 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003820 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3821 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003822 return skip;
3823}
3824
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003825bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003826 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003827 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003828
3829 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3830 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003831 bool cb_is_secondary;
3832 {
3833 auto lock = cb_read_lock();
3834 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3835 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003836
Tony-LunarG3c287f62020-12-17 12:39:49 -07003837 if (cb_is_secondary) {
3838 // Implicit VUs
3839 // validate only sType here; pointer has to be validated in core_validation
3840 const bool k_not_required = false;
3841 const char *k_no_vuid = nullptr;
3842 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3843 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003844 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3845 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003846
Tony-LunarG3c287f62020-12-17 12:39:49 -07003847 if (info) {
3848 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07003849 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
3850 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003851 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003852 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3853 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3854 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3855 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003856
Tony-LunarG3c287f62020-12-17 12:39:49 -07003857 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003858
Tony-LunarG3c287f62020-12-17 12:39:49 -07003859 // Explicit VUs
3860 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003861 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003862 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3863 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3864 cmd_name);
3865 }
3866
3867 if (physical_device_features.inheritedQueries) {
3868 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003869 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3870 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3871 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003872 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003873 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003874 }
3875
3876 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003877 skip |=
3878 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
3879 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
3880 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
3881 } else { // !pipelineStatisticsQuery
3882 skip |=
3883 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
3884 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003885 }
3886
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003887 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003888 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003889 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003890 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3891 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
3892 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003893 commandBuffer,
3894 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07003895 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3896 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3897 }
Petr Kraus139757b2019-08-15 17:19:33 +02003898 }
ziga-lunarg9d019132021-07-19 01:05:31 +02003899
3900 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
3901 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
3902 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
3903 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
3904 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
3905 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
3906 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
3907 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
3908 }
Petr Kraus139757b2019-08-15 17:19:33 +02003909 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003910 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003911 return skip;
3912}
3913
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003914bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003915 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003916 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003917
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003918 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003919 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003920 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3921 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3922 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003923 }
3924 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003925 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3926 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3927 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003928 }
3929 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003930 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003931 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003932 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3933 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3934 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3935 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003936 }
3937 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003938
3939 if (pViewports) {
3940 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3941 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003942 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003943 skip |= manual_PreCallValidateViewport(
3944 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003945 }
3946 }
3947
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003948 return skip;
3949}
3950
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003951bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003952 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003953 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003954
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003955 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003956 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003957 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3958 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3959 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003960 }
3961 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003962 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3963 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3964 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003965 }
3966 } else { // multiViewport enabled
3967 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003968 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003969 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3970 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3971 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3972 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003973 }
3974 }
3975
Petr Kraus6260f0a2018-02-27 21:15:55 +01003976 if (pScissors) {
3977 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3978 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003979
Petr Kraus6260f0a2018-02-27 21:15:55 +01003980 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003981 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3982 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3983 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003984 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003985
Petr Kraus6260f0a2018-02-27 21:15:55 +01003986 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003987 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3988 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3989 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003990 }
3991
3992 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3993 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003994 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3995 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3996 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3997 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003998 }
3999
4000 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4001 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004002 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4003 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4004 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4005 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004006 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004007 }
4008 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004009
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004010 return skip;
4011}
4012
Jeff Bolz5c801d12019-10-09 10:38:45 -05004013bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004014 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004015
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004016 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004017 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4018 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004019 }
4020
4021 return skip;
4022}
4023
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004024bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004025 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004026 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004027
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004028 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004029 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004030 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
4031 }
4032 if (drawCount > device_limits.maxDrawIndirectCount) {
4033 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004034 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
4035 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004036 }
4037 return skip;
4038}
4039
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004040bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004041 VkDeviceSize offset, uint32_t drawCount,
4042 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004043 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004044 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004045 skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4046 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
4047 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004048 }
4049 if (drawCount > device_limits.maxDrawIndirectCount) {
4050 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004051 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4052 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004053 }
4054 return skip;
4055}
4056
sfricke-samsungf692b972020-05-02 08:00:45 -07004057bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4058 VkDeviceSize countBufferOffset, bool khr) const {
4059 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004060 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004061 if (offset & 3) {
4062 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004063 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004064 }
4065
4066 if (countBufferOffset & 3) {
4067 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004068 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004069 countBufferOffset);
4070 }
4071 return skip;
4072}
4073
4074bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4075 VkDeviceSize offset, VkBuffer countBuffer,
4076 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4077 uint32_t stride) const {
4078 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4079}
4080
4081bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4082 VkDeviceSize offset, VkBuffer countBuffer,
4083 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4084 uint32_t stride) const {
4085 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4086}
4087
4088bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4089 VkDeviceSize countBufferOffset, bool khr) const {
4090 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004091 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004092 if (offset & 3) {
4093 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004094 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004095 }
4096
4097 if (countBufferOffset & 3) {
4098 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004099 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004100 countBufferOffset);
4101 }
4102 return skip;
4103}
4104
4105bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4106 VkDeviceSize offset, VkBuffer countBuffer,
4107 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4108 uint32_t stride) const {
4109 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4110}
4111
4112bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4113 VkDeviceSize offset, VkBuffer countBuffer,
4114 VkDeviceSize countBufferOffset,
4115 uint32_t maxDrawCount, uint32_t stride) const {
4116 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4117}
4118
Tony-LunarG4490de42021-06-21 15:49:19 -06004119bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4120 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4121 uint32_t firstInstance, uint32_t stride) const {
4122 bool skip = false;
4123 if (stride & 3) {
4124 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4125 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4126 }
4127 if (drawCount && nullptr == pVertexInfo) {
4128 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4129 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4130 "one or more valid instances of VkMultiDrawInfoEXT structures");
4131 }
4132 return skip;
4133}
4134
4135bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4136 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4137 uint32_t instanceCount, uint32_t firstInstance,
4138 uint32_t stride, const int32_t *pVertexOffset) const {
4139 bool skip = false;
4140 if (stride & 3) {
4141 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4142 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4143 }
4144 if (drawCount && nullptr == pIndexInfo) {
4145 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4146 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4147 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4148 }
4149 return skip;
4150}
4151
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004152bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4153 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004154 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004155 bool skip = false;
4156 for (uint32_t rect = 0; rect < rectCount; rect++) {
4157 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004158 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
4159 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004160 }
sfricke-samsung10867682020-04-25 02:20:39 -07004161 if (pRects[rect].rect.extent.width == 0) {
4162 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
4163 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
4164 }
4165 if (pRects[rect].rect.extent.height == 0) {
4166 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
4167 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
4168 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004169 }
4170 return skip;
4171}
4172
Andrew Fobel3abeb992020-01-20 16:33:22 -05004173bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4174 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4175 VkImageFormatProperties2 *pImageFormatProperties,
4176 const char *apiName) const {
4177 bool skip = false;
4178
4179 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004180 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004181 if (image_stencil_struct != nullptr) {
4182 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4183 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4184 // No flags other than the legal attachment bits may be set
4185 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4186 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004187 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4188 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4189 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4190 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4191 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004192 }
4193 }
4194 }
4195 }
4196
4197 return skip;
4198}
4199
4200bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4201 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4202 VkImageFormatProperties2 *pImageFormatProperties) const {
4203 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4204 "vkGetPhysicalDeviceImageFormatProperties2");
4205}
4206
4207bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4208 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4209 VkImageFormatProperties2 *pImageFormatProperties) const {
4210 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4211 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4212}
4213
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004214bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4215 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4216 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4217 bool skip = false;
4218
4219 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4220 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4221 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4222 }
4223
4224 return skip;
4225}
4226
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004227bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4228 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4229 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4230 bool skip = false;
4231
4232 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4233 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4234 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4235 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4236 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4237 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4238 }
4239
4240 return false;
4241}
4242
sfricke-samsung3999ef62020-02-09 17:05:59 -08004243bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4244 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4245 bool skip = false;
4246
4247 if (pRegions != nullptr) {
4248 for (uint32_t i = 0; i < regionCount; i++) {
4249 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004250 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
4251 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004252 }
4253 }
4254 }
4255 return skip;
4256}
4257
Jeff Leger178b1e52020-10-05 12:22:23 -04004258bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4259 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4260 bool skip = false;
4261
4262 if (pCopyBufferInfo->pRegions != nullptr) {
4263 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4264 if (pCopyBufferInfo->pRegions[i].size == 0) {
4265 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
4266 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
4267 }
4268 }
4269 }
4270 return skip;
4271}
4272
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004273bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004274 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4275 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004276 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004277
4278 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004279 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4280 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4281 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004282 }
4283
4284 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004285 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4286 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4287 "), must be greater than zero and less than or equal to 65536.",
4288 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004289 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004290 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4291 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4292 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004293 }
4294 return skip;
4295}
4296
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004297bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004298 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004299 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004300
4301 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004302 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4303 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4304 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004305 }
4306
4307 if (size != VK_WHOLE_SIZE) {
4308 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004309 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004310 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4311 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004312 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004313 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4314 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004315 }
4316 }
4317 return skip;
4318}
4319
sfricke-samsunga1d00272021-03-10 21:37:41 -08004320bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004321 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004322
4323 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004324 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4325 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4326 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4327 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004328 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004329 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4330 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4331 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004332 }
4333
4334 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4335 // queueFamilyIndexCount uint32_t values
4336 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004337 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004338 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004339 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004340 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4341 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004342 }
4343 }
4344
Dave Houlton413a6782018-05-22 13:01:54 -06004345 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004346 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004347
sfricke-samsunga1d00272021-03-10 21:37:41 -08004348 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4349 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4350 if (format_list_info) {
4351 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4352 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4353 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4354 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
4355 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1 if it is in the pNext chain.",
4356 func_name, viewFormatCount);
4357 }
4358
4359 // Using the first format, compare the rest of the formats against it that they are compatible
4360 for (uint32_t i = 1; i < viewFormatCount; i++) {
4361 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4362 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4363 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4364 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
4365 "VkImageFormatListCreateInfo::pViewFormats[%u] (%s) are not compatible in the pNext chain.",
4366 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4367 string_VkFormat(format_list_info->pViewFormats[i]));
4368 }
4369 }
4370 }
4371
4372 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4373 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4374 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4375 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4376 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4377 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4378 func_name);
4379 } else {
4380 if (format_list_info == nullptr) {
4381 skip |= LogError(
4382 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4383 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4384 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4385 func_name);
4386 } else if (format_list_info->viewFormatCount == 0) {
4387 skip |= LogError(
4388 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4389 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4390 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4391 func_name);
4392 } else {
4393 bool found_base_format = false;
4394 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4395 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4396 found_base_format = true;
4397 break;
4398 }
4399 }
4400 if (!found_base_format) {
4401 skip |=
4402 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4403 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4404 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4405 "pCreateInfo->imageFormat.",
4406 func_name);
4407 }
4408 }
4409 }
4410 }
4411 }
4412 return skip;
4413}
4414
4415bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4416 const VkAllocationCallbacks *pAllocator,
4417 VkSwapchainKHR *pSwapchain) const {
4418 bool skip = false;
4419 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4420 return skip;
4421}
4422
4423bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4424 const VkSwapchainCreateInfoKHR *pCreateInfos,
4425 const VkAllocationCallbacks *pAllocator,
4426 VkSwapchainKHR *pSwapchains) const {
4427 bool skip = false;
4428 if (pCreateInfos) {
4429 for (uint32_t i = 0; i < swapchainCount; i++) {
4430 std::stringstream func_name;
4431 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4432 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4433 }
4434 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004435 return skip;
4436}
4437
Jeff Bolz5c801d12019-10-09 10:38:45 -05004438bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004439 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004440
4441 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004442 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004443 if (present_regions) {
4444 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004445 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004446 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4447 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004448 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004449 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4450 "extension swapchainCount is %i. These values must be equal.",
4451 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004452 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004453 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004454 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4455 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004456 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4457 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4458 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004459 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004460 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004461 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004462 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004463 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004464 }
4465 }
4466
4467 return skip;
4468}
4469
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004470bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4471 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4472 const VkAllocationCallbacks *pAllocator,
4473 VkDisplayModeKHR *pMode) const {
4474 bool skip = false;
4475
4476 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4477 if (display_mode_parameters.visibleRegion.width == 0) {
4478 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4479 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4480 }
4481 if (display_mode_parameters.visibleRegion.height == 0) {
4482 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4483 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4484 }
4485 if (display_mode_parameters.refreshRate == 0) {
4486 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4487 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4488 }
4489
4490 return skip;
4491}
4492
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004493#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004494bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4495 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4496 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004497 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004498 bool skip = false;
4499
4500 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004501 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4502 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004503 }
4504
4505 return skip;
4506}
4507#endif // VK_USE_PLATFORM_WIN32_KHR
4508
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004509bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004510 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004511 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004512 bool skip = false;
4513
4514 if (pCreateInfo) {
4515 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004516 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4517 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004518 }
4519
4520 if (pCreateInfo->pPoolSizes) {
4521 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4522 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004523 skip |= LogError(
4524 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004525 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004526 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004527 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4528 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004529 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4530 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4531 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4532 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4533 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004534 }
Petr Krausc8655be2017-09-27 18:56:51 +02004535 }
4536 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02004537
4538 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
4539 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
4540 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
4541 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
4542 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
4543 }
Petr Krausc8655be2017-09-27 18:56:51 +02004544 }
4545
4546 return skip;
4547}
4548
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004549bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004550 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004551 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004552
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004553 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004554 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004555 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4556 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4557 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004558 }
4559
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004560 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004561 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004562 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4563 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4564 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004565 }
4566
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004567 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004568 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004569 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4570 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4571 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004572 }
4573
4574 return skip;
4575}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004576
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004577bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004578 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004579 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004580
4581 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004582 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
4583 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07004584 }
4585 return skip;
4586}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004587
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004588bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4589 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004590 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004591 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004592
4593 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004594 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004595 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004596 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4597 "vkCmdDispatch(): baseGroupX (%" PRIu32
4598 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4599 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004600 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004601 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4602 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4603 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4604 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004605 }
4606
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004607 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004608 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004609 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4610 "vkCmdDispatch(): baseGroupY (%" PRIu32
4611 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4612 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004613 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004614 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4615 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4616 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4617 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004618 }
4619
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004620 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004621 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004622 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4623 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4624 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4625 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004626 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004627 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4628 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4629 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4630 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004631 }
4632
4633 return skip;
4634}
4635
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004636bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4637 VkPipelineBindPoint pipelineBindPoint,
4638 VkPipelineLayout layout, uint32_t set,
4639 uint32_t descriptorWriteCount,
4640 const VkWriteDescriptorSet *pDescriptorWrites) const {
4641 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4642}
4643
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004644bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4645 uint32_t firstExclusiveScissor,
4646 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004647 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004648 bool skip = false;
4649
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004650 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004651 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004652 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004653 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4654 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4655 ") is not 0.",
4656 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004657 }
4658 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004659 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004660 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4661 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4662 ") is not 1.",
4663 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004664 }
4665 } else { // multiViewport enabled
4666 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004667 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004668 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4669 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4670 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4671 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004672 }
4673 }
4674
Jeff Bolz3e71f782018-08-29 23:15:45 -05004675 if (pExclusiveScissors) {
4676 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4677 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4678
4679 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004680 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4681 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4682 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004683 }
4684
4685 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004686 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4687 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4688 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004689 }
4690
4691 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4692 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004693 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4694 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4695 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4696 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004697 }
4698
4699 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4700 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004701 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4702 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4703 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4704 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004705 }
4706 }
4707 }
4708
4709 return skip;
4710}
4711
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004712bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4713 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004714 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004715 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004716 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4717 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4718 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4719 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4720 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4721 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004722 }
4723
4724 return skip;
4725}
4726
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004727bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4728 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004729 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004730 bool skip = false;
4731
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004732 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004733 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004734 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004735 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4736 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4737 ") is not 0.",
4738 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004739 }
4740 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004741 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004742 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4743 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4744 ") is not 1.",
4745 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004746 }
4747 }
4748
Jeff Bolz9af91c52018-09-01 21:53:57 -05004749 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004750 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004751 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4752 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4753 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4754 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004755 }
4756
4757 return skip;
4758}
4759
Jeff Bolz5c801d12019-10-09 10:38:45 -05004760bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4761 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4762 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004763 bool skip = false;
4764
Dave Houlton142c4cb2018-10-17 15:04:41 -06004765 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004766 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4767 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4768 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004769 }
4770
4771 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004772 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004773 }
4774
4775 return skip;
4776}
4777
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004778bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004779 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004780 bool skip = false;
4781
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004782 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004783 skip |= LogError(
4784 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004785 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4786 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004787 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004788 }
4789
4790 return skip;
4791}
4792
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004793bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4794 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004795 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004796 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004797 static const int condition_multiples = 0b0011;
4798 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004799 skip |= LogError(
4800 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004801 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004802 }
Lockee1c22882019-06-10 16:02:54 -06004803 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004804 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4805 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4806 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4807 stride);
Lockee1c22882019-06-10 16:02:54 -06004808 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004809 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004810 skip |= LogError(
4811 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4812 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004813 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004814 if (drawCount > device_limits.maxDrawIndirectCount) {
4815 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004816 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4817 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004818 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004819 return skip;
4820}
4821
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004822bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4823 VkDeviceSize offset, VkBuffer countBuffer,
4824 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004825 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004826 bool skip = false;
4827
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004828 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004829 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4830 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4831 "), is not a multiple of 4.",
4832 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004833 }
4834
4835 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004836 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4837 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4838 "), is not a multiple of 4.",
4839 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004840 }
4841
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004842 return skip;
4843}
4844
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004845bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004846 const VkAllocationCallbacks *pAllocator,
4847 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004848 bool skip = false;
4849
4850 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4851 if (pCreateInfo != nullptr) {
4852 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4853 // VkQueryPipelineStatisticFlagBits values
4854 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4855 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004856 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4857 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4858 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4859 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004860 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004861 if (pCreateInfo->queryCount == 0) {
4862 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4863 "vkCreateQueryPool(): queryCount must be greater than zero.");
4864 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004865 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004866 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004867}
4868
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004869bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4870 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004871 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004872 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4873 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004874}
4875
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004876void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004877 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4878 VkResult result) {
4879 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004880 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004881}
4882
Mike Schuchardt2df08912020-12-15 16:28:09 -08004883void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004884 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4885 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004886 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004887 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004888 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004889}
4890
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004891void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4892 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004893 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004894 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004895 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004896}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004897
Tony-LunarG3c287f62020-12-17 12:39:49 -07004898void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004899 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004900 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
4901 auto lock = cb_write_lock();
4902 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06004903 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004904 }
4905 }
4906}
4907
4908void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004909 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004910 auto lock = cb_write_lock();
4911 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
4912 secondary_cb_map.erase(pCommandBuffers[cb_index]);
4913 }
4914}
4915
4916void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004917 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004918 auto lock = cb_write_lock();
4919 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
4920 if (item->second == commandPool) {
4921 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004922 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004923 ++item;
4924 }
4925 }
4926}
4927
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004928bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004929 const VkAllocationCallbacks *pAllocator,
4930 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004931 bool skip = false;
4932
4933 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004934 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004935 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004936 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4937 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004938 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004939
4940 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004941 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004942 if (flags_info) {
4943 flags = flags_info->flags;
4944 }
4945
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004946 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004947 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08004948 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004949 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4950 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08004951 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004952 }
4953
4954#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004955 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004956#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004957 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4958 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004959#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004960 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004961#endif
4962
4963 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004964 skip |= LogError(
4965 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004966 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4967 }
4968 if (
4969#ifdef VK_USE_PLATFORM_WIN32_KHR
4970 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4971#endif
4972 (import_memory_fd && import_memory_fd->handleType) ||
4973#ifdef VK_USE_PLATFORM_ANDROID_KHR
4974 (import_memory_ahb && import_memory_ahb->buffer) ||
4975#endif
4976 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004977 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4978 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004979 }
4980 }
4981
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02004982 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
4983 if (export_memory) {
4984 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
4985 if (export_memory_nv) {
4986 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
4987 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
4988 "VkExportMemoryAllocateInfoNV");
4989 }
4990#ifdef VK_USE_PLATFORM_WIN32_KHR
4991 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
4992 if (export_memory_win32_nv) {
4993 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
4994 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
4995 "VkExportMemoryWin32HandleInfoNV");
4996 }
4997#endif
4998 }
4999
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005000 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005001 VkBool32 capture_replay = false;
5002 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005003 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005004 if (vulkan_12_features) {
5005 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5006 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5007 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005008 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005009 if (bda_features) {
5010 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5011 buffer_device_address = bda_features->bufferDeviceAddress;
5012 }
5013 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005014 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005015 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005016 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005017 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005018 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005019 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005020 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005021 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005022 }
5023 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005024 }
5025 return skip;
5026}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005027
Jason Macnak192fa0e2019-07-26 15:07:16 -07005028bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005029 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005030 bool skip = false;
5031
5032 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5033 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5034 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005035 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005036 } else {
5037 uint32_t vertex_component_size = 0;
5038 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5039 vertex_component_size = 4;
5040 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5041 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5042 vertex_component_size = 2;
5043 }
5044 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005045 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005046 }
5047 }
5048
5049 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5050 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005051 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005052 } else {
5053 uint32_t index_element_size = 0;
5054 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5055 index_element_size = 4;
5056 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5057 index_element_size = 2;
5058 }
5059 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005060 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005061 }
5062 }
5063 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5064 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005065 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005066 }
5067 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005068 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005069 }
5070 }
5071
5072 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005073 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005074 }
5075
5076 return skip;
5077}
5078
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005079bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5080 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005081 bool skip = false;
5082
5083 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005084 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005085 }
5086 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005087 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005088 }
5089
5090 return skip;
5091}
5092
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005093bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5094 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005095 bool skip = false;
5096 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005097 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005098 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005099 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005100 }
5101 return skip;
5102}
5103
5104bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005105 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005106 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005107 bool skip = false;
5108 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005109 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5110 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5111 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005112 }
5113 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005114 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5115 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5116 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005117 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005118 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5119 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5120 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5121 }
Jason Macnak5c954952019-07-09 15:46:12 -07005122 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5123 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005124 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5125 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5126 "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 -07005127 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005128 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005129 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005130 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5131 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005132 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5133 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005134 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005135 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005136 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5137 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5138 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005139 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005140 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005141 uint64_t total_triangle_count = 0;
5142 for (uint32_t i = 0; i < info.geometryCount; i++) {
5143 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005144
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005145 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005146
Jason Macnak5c954952019-07-09 15:46:12 -07005147 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5148 continue;
5149 }
5150 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5151 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005152 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005153 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5154 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5155 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005156 }
5157 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005158 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5159 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5160 for (uint32_t i = 1; i < info.geometryCount; i++) {
5161 const VkGeometryNV &geometry = info.pGeometries[i];
5162 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005163 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005164 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
5165 "info.pGeometries[0].geometryType.",
5166 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005167 }
5168 }
5169 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005170 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5171 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5172 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5173 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5174 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5175 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5176 }
5177 }
5178 skip |=
5179 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005180 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005181 return skip;
5182}
5183
Ricardo Garciaa4935972019-02-21 17:43:18 +01005184bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5185 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005186 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005187 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005188 if (pCreateInfo) {
5189 if ((pCreateInfo->compactedSize != 0) &&
5190 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005191 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5192 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5193 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5194 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005195 }
Jason Macnak5c954952019-07-09 15:46:12 -07005196
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005197 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005198 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005199 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005200 return skip;
5201}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005202
Jeff Bolz5c801d12019-10-09 10:38:45 -05005203bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5204 const VkAccelerationStructureInfoNV *pInfo,
5205 VkBuffer instanceData, VkDeviceSize instanceOffset,
5206 VkBool32 update, VkAccelerationStructureNV dst,
5207 VkAccelerationStructureNV src, VkBuffer scratch,
5208 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005209 bool skip = false;
5210
5211 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005212 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005213 }
5214
5215 return skip;
5216}
5217
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005218bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5219 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5220 VkAccelerationStructureKHR *pAccelerationStructure) const {
5221 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005222 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005223 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005224 if (!acceleration_structure_features ||
5225 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5226 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5227 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5228 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005229 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005230 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5231 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005232 (acceleration_structure_features &&
5233 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005234 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005235 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5236 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5237 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5238 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005239 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005240 if (pCreateInfo->deviceAddress &&
5241 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5242 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5243 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5244 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5245 }
5246 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5247 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005248 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes", pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005249 }
sourav parmar83c31b12020-05-06 12:30:54 -07005250 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005251 return skip;
5252}
5253
Jason Macnak5c954952019-07-09 15:46:12 -07005254bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5255 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005256 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005257 bool skip = false;
5258 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005259 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5260 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005261 }
5262 return skip;
5263}
5264
sourav parmarcd5fb182020-07-17 12:58:44 -07005265bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5266 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5267 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5268 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005269 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07005270 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07005271 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005272 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005273 }
5274 return skip;
5275}
5276
Peter Chen85366392019-05-14 15:20:11 -04005277bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5278 uint32_t createInfoCount,
5279 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5280 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005281 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005282 bool skip = false;
5283
5284 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005285 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5286 std::stringstream msg;
5287 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5288 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
5289 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005290 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005291 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005292 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005293 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5294 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5295 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5296 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005297 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005298
5299 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005300 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005301 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5302 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5303 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5304 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5305 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5306 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5307 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5308 }
5309 }
5310
sourav parmarf4a78252020-04-10 13:04:21 -07005311 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5312 skip |=
5313 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5314 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5315 }
5316 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5317 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5318 skip |=
5319 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5320 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5321 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5322 }
5323 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5324 if (pCreateInfos[i].basePipelineIndex != -1) {
5325 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5326 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5327 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5328 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5329 "and pCreateInfos->basePipelineIndex is not -1.");
5330 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005331 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005332 skip |=
5333 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5334 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5335 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5336 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5337 "that element.");
5338 }
sourav parmarf4a78252020-04-10 13:04:21 -07005339 }
5340 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005341 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005342 skip |=
5343 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5344 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5345 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5346 "commands pCreateInfos parameter.");
5347 }
5348 } else {
5349 if (pCreateInfos[i].basePipelineIndex != -1) {
5350 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5351 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5352 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5353 }
5354 }
5355 }
5356 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5357 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5358 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5359 }
5360 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5361 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5362 "vkCreateRayTracingPipelinesNV: flags must not include "
5363 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5364 }
5365 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5366 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5367 "vkCreateRayTracingPipelinesNV: flags must not include "
5368 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5369 }
5370 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5371 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5372 "vkCreateRayTracingPipelinesNV: flags must not include "
5373 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5374 }
5375 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5376 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5377 "vkCreateRayTracingPipelinesNV: flags must not include "
5378 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5379 }
5380 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5381 skip |= LogError(
5382 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5383 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5384 }
5385 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5386 skip |= LogError(
5387 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5388 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5389 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005390 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5391 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5392 "vkCreateRayTracingPipelinesNV: flags must not include "
5393 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5394 }
5395 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5396 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5397 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5398 }
Peter Chen85366392019-05-14 15:20:11 -04005399 }
5400
5401 return skip;
5402}
5403
sourav parmarcd5fb182020-07-17 12:58:44 -07005404bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5405 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5406 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005407 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005408 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005409 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5410 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5411 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005412 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005413 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005414 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5415 std::stringstream msg;
5416 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5417 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
5418 &pCreateInfos[i].pStages[i]);
5419 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005420 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5421 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5422 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5423 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5424 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5425 }
5426 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5427 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5428 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5429 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
5430 }
5431 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005432 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005433 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
5434 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07005435 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
5436 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
5437 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005438 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
5439 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
5440 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005441 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005442 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005443 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5444 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5445 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5446 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07005447 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07005448 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5449 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5450 }
5451 }
sourav parmarf4a78252020-04-10 13:04:21 -07005452 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005453 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
5454 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07005455 }
5456 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005457 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07005458 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07005459 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
5460 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005461 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005462 }
5463 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5464 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
5465 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07005466 }
5467 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
5468 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
5469 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
5470 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
5471 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
5472 skip |= LogError(
5473 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07005474 "vkCreateRayTracingPipelinesKHR: If flags includes "
5475 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005476 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5477 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
5478 "must not be VK_SHADER_UNUSED_KHR");
5479 }
5480 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
5481 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
5482 skip |= LogError(
5483 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07005484 "vkCreateRayTracingPipelinesKHR: If flags includes "
5485 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005486 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5487 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
5488 "element must not be VK_SHADER_UNUSED_KHR");
5489 }
5490 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005491 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
5492 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
5493 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
5494 skip |= LogError(
5495 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
5496 "vkCreateRayTracingPipelinesKHR: If "
5497 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
5498 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
5499 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5500 }
5501 }
sourav parmarf4a78252020-04-10 13:04:21 -07005502 }
5503 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5504 if (pCreateInfos[i].basePipelineIndex != -1) {
5505 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5506 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07005507 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07005508 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5509 "and pCreateInfos->basePipelineIndex is not -1.");
5510 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005511 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005512 skip |=
5513 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
5514 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
5515 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
5516 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
5517 "element.");
5518 }
sourav parmarf4a78252020-04-10 13:04:21 -07005519 }
5520 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005521 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005522 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005523 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005524 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
5525 "commands pCreateInfos parameter %d.",
5526 pCreateInfos[i].basePipelineIndex, createInfoCount);
5527 }
5528 } else {
5529 if (pCreateInfos[i].basePipelineIndex != -1) {
5530 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07005531 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005532 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5533 }
5534 }
5535 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005536 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
5537 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
5538 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
5539 "vkCreateRayTracingPipelinesKHR: If flags includes "
5540 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
5541 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005542 }
5543 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
5544 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
5545 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
5546 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
5547 "pLibraryInfo and pLibraryInterface must be NULL.");
5548 }
5549 if (pCreateInfos[i].pLibraryInfo) {
5550 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
5551 if (pCreateInfos[i].stageCount == 0) {
5552 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
5553 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5554 "stageCount must not be 0.");
5555 }
5556 if (pCreateInfos[i].groupCount == 0) {
5557 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
5558 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5559 "groupCount must not be 0.");
5560 }
5561 } else {
5562 if (pCreateInfos[i].pLibraryInterface == NULL) {
5563 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
5564 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
5565 "is greater than 0, its "
5566 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005567 }
5568 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005569 }
5570 if (pCreateInfos[i].pLibraryInterface) {
5571 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
5572 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
5573 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
5574 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
5575 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
5576 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005577 }
5578 if (deferredOperation != VK_NULL_HANDLE) {
5579 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
5580 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
5581 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
5582 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07005583 }
5584 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005585 }
5586
5587 return skip;
5588}
5589
Mike Schuchardt21638df2019-03-16 10:52:02 -07005590#ifdef VK_USE_PLATFORM_WIN32_KHR
5591bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
5592 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005593 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07005594 bool skip = false;
5595 if (!device_extensions.vk_khr_swapchain)
5596 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
Mike Schuchardtc57de4a2021-07-20 17:26:32 -07005597 if (!device_extensions.vk_khr_get_surface_capabilities2)
Mike Schuchardt21638df2019-03-16 10:52:02 -07005598 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
5599 if (!device_extensions.vk_khr_surface)
5600 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
Mike Schuchardtc57de4a2021-07-20 17:26:32 -07005601 if (!device_extensions.vk_khr_get_physical_device_properties2)
Mike Schuchardt21638df2019-03-16 10:52:02 -07005602 skip |=
5603 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
5604 if (!device_extensions.vk_ext_full_screen_exclusive)
5605 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
5606 skip |= validate_struct_type(
5607 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
5608 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
5609 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
5610 if (pSurfaceInfo != NULL) {
5611 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
5612 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
5613 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
5614
5615 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
5616 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
5617 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5618 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005619 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5620 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005621
5622 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5623 }
5624 return skip;
5625}
5626#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005627
5628bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5629 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005630 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005631 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5632 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005633 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005634 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5635 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5636 }
5637 return skip;
5638}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005639
5640bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005641 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005642 bool skip = false;
5643
5644 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005645 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
5646 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005647 }
5648
5649 return skip;
5650}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005651
5652bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005653 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005654 bool skip = false;
5655
5656 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005657 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5658 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005659 }
5660
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005661 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005662 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005663 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5664 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005665 }
5666
5667 return skip;
5668}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005669
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005670bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5671 uint32_t bindingCount, const VkBuffer *pBuffers,
5672 const VkDeviceSize *pOffsets) const {
5673 bool skip = false;
5674 if (firstBinding > device_limits.maxVertexInputBindings) {
5675 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5676 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
5677 device_limits.maxVertexInputBindings);
5678 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5679 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
5680 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5681 "maxVertexInputBindings (%u)",
5682 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5683 }
5684
Jeff Bolz165818a2020-05-08 11:19:03 -05005685 for (uint32_t i = 0; i < bindingCount; ++i) {
5686 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005687 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005688 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5689 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5690 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5691 } else {
5692 if (pOffsets[i] != 0) {
5693 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5694 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5695 }
5696 }
5697 }
5698 }
5699
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005700 return skip;
5701}
5702
Mark Lobodzinski84988402019-09-11 15:27:30 -06005703bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005704 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005705 bool skip = false;
5706 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005707 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5708 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005709 }
5710 return skip;
5711}
5712
5713bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005714 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005715 bool skip = false;
5716 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005717 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5718 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005719 }
5720 return skip;
5721}
Petr Kraus3d720392019-11-13 02:52:39 +01005722
5723bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5724 VkSemaphore semaphore, VkFence fence,
5725 uint32_t *pImageIndex) const {
5726 bool skip = false;
5727
5728 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005729 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5730 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005731 }
5732
5733 return skip;
5734}
5735
5736bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5737 uint32_t *pImageIndex) const {
5738 bool skip = false;
5739
5740 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005741 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5742 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005743 }
5744
5745 return skip;
5746}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005747
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005748bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5749 uint32_t firstBinding, uint32_t bindingCount,
5750 const VkBuffer *pBuffers,
5751 const VkDeviceSize *pOffsets,
5752 const VkDeviceSize *pSizes) const {
5753 bool skip = false;
5754
5755 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5756 for (uint32_t i = 0; i < bindingCount; ++i) {
5757 if (pOffsets[i] & 3) {
5758 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5759 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5760 }
5761 }
5762
5763 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5764 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5765 "%s: The firstBinding(%" PRIu32
5766 ") index is greater than or equal to "
5767 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5768 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5769 }
5770
5771 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5772 skip |=
5773 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5774 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5775 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5776 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5777 }
5778
5779 for (uint32_t i = 0; i < bindingCount; ++i) {
5780 // pSizes is optional and may be nullptr.
5781 if (pSizes != nullptr) {
5782 if (pSizes[i] != VK_WHOLE_SIZE &&
5783 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5784 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5785 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5786 ") is not VK_WHOLE_SIZE and is greater than "
5787 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5788 cmd_name, i, pSizes[i]);
5789 }
5790 }
5791 }
5792
5793 return skip;
5794}
5795
5796bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5797 uint32_t firstCounterBuffer,
5798 uint32_t counterBufferCount,
5799 const VkBuffer *pCounterBuffers,
5800 const VkDeviceSize *pCounterBufferOffsets) const {
5801 bool skip = false;
5802
5803 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5804 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5805 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5806 "%s: The firstCounterBuffer(%" PRIu32
5807 ") index is greater than or equal to "
5808 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5809 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5810 }
5811
5812 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5813 skip |=
5814 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5815 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5816 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5817 cmd_name, firstCounterBuffer, counterBufferCount,
5818 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5819 }
5820
5821 return skip;
5822}
5823
5824bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5825 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5826 const VkBuffer *pCounterBuffers,
5827 const VkDeviceSize *pCounterBufferOffsets) const {
5828 bool skip = false;
5829
5830 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5831 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5832 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5833 "%s: The firstCounterBuffer(%" PRIu32
5834 ") index is greater than or equal to "
5835 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5836 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5837 }
5838
5839 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5840 skip |=
5841 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5842 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5843 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5844 cmd_name, firstCounterBuffer, counterBufferCount,
5845 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5846 }
5847
5848 return skip;
5849}
5850
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005851bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5852 uint32_t firstInstance, VkBuffer counterBuffer,
5853 VkDeviceSize counterBufferOffset,
5854 uint32_t counterOffset, uint32_t vertexStride) const {
5855 bool skip = false;
5856
5857 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005858 skip |= LogError(
5859 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005860 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5861 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5862 }
5863
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005864 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08005865 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005866 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005867 }
5868
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005869 return skip;
5870}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005871
5872bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5873 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5874 const VkAllocationCallbacks *pAllocator,
5875 VkSamplerYcbcrConversion *pYcbcrConversion,
5876 const char *apiName) const {
5877 bool skip = false;
5878
5879 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005880 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005881 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005882 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005883 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5884 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005885 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005886 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005887 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005888
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005889#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005890 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005891 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005892#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005893 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005894#endif
5895
sfricke-samsung1a72f942020-07-25 12:09:18 -07005896 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005897
5898 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005899 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005900 const VkComponentMapping components = pCreateInfo->components;
5901 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5902 if (FormatIsXChromaSubsampled(format) == true) {
5903 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5904 skip |=
5905 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005906 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5907 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005908 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005909 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005910
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005911 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5912 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5913 skip |= LogError(
5914 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5915 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5916 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5917 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5918 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005919
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005920 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5921 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5922 skip |=
5923 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005924 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5925 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005926 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005927 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005928
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005929 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5930 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5931 skip |=
5932 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005933 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5934 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005935 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005936 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005937
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005938 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005939 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5940 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5941 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005942 skip |=
5943 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005944 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5945 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005946 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5947 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005948 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005949 }
5950
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005951 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5952 // Checks same VU multiple ways in order to give a more useful error message
5953 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5954 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5955 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5956 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5957 skip |= LogError(
5958 device, vuid,
5959 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5960 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5961 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5962 string_VkComponentSwizzle(components.b));
5963 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005964
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005965 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5966 // 4 channel format = no issue
5967 // 3 = no [a]
5968 // 2 = no [b,a]
5969 // 1 = no [g,b,a]
5970 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5971 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5972
5973 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5974 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5975 skip |= LogError(device, vuid,
5976 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5977 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5978 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5979 string_VkComponentSwizzle(components.b));
5980 } else if ((channels < 3) &&
5981 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5982 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5983 skip |= LogError(device, vuid,
5984 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5985 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5986 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5987 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5988 string_VkComponentSwizzle(components.b));
5989 } else if ((channels < 2) &&
5990 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5991 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5992 skip |= LogError(device, vuid,
5993 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5994 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5995 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5996 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5997 string_VkComponentSwizzle(components.b));
5998 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005999 }
6000 }
6001
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006002 return skip;
6003}
6004
6005bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6006 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6007 const VkAllocationCallbacks *pAllocator,
6008 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6009 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6010 "vkCreateSamplerYcbcrConversion");
6011}
6012
6013bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6014 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6015 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6016 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6017 "vkCreateSamplerYcbcrConversionKHR");
6018}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006019
6020bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6021 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6022 bool skip = false;
6023 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6024 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6025
6026 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006027 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6028 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6029 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6030 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6031 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006032 }
6033 return skip;
6034}
sourav parmara96ab1a2020-04-25 16:28:23 -07006035
6036bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006037 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006038 bool skip = false;
6039 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6040 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6041 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6042 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006043 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006044 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6045 skip |= LogError(
6046 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6047 "vkCopyAccelerationStructureToMemoryKHR: The "
6048 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6049 }
6050 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6051 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6052 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6053 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6054 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6055 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006056 return skip;
6057}
6058
6059bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6060 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6061 bool skip = false;
6062 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6063 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6064 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6065 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6066 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006067 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6068 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006069 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006070 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006071 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006072 return skip;
6073}
6074
6075bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6076 const char *api_name) const {
6077 bool skip = false;
6078 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6079 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6080 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6081 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6082 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6083 api_name);
6084 }
6085 return skip;
6086}
6087
6088bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006089 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006090 bool skip = false;
6091 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006092 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006093 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006094 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006095 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6096 "vkCopyAccelerationStructureKHR: The "
6097 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006098 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006099 return skip;
6100}
6101
6102bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6103 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6104 bool skip = false;
6105 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6106 return skip;
6107}
6108
6109bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006110 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006111 bool skip = false;
6112 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006113 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006114 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6115 }
6116 return skip;
6117}
6118
6119bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006120 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006121 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006122 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006123 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006124 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6125 skip |= LogError(
6126 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6127 "vkCopyMemoryToAccelerationStructureKHR: The "
6128 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006129 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006130 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6131 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006132 return skip;
6133}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006134
sourav parmara96ab1a2020-04-25 16:28:23 -07006135bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6136 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6137 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006138 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006139 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6140 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006141 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006142 pInfo->src.deviceAddress);
6143 }
sourav parmar83c31b12020-05-06 12:30:54 -07006144 return skip;
6145}
6146bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6147 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6148 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6149 bool skip = false;
6150 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6151 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6152 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6153 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6154 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6155 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6156 }
6157 return skip;
6158}
6159bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6160 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6161 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6162 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006163 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006164 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6165 skip |= LogError(
6166 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6167 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6168 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6169 }
sourav parmar83c31b12020-05-06 12:30:54 -07006170 if (dataSize < accelerationStructureCount * stride) {
6171 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6172 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
6173 "accelerationStructureCount (%d) *stride(%zu).",
6174 dataSize, accelerationStructureCount, stride);
6175 }
6176 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6177 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6178 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6179 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6180 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6181 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6182 }
6183 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6184 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6185 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6186 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6187 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6188 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6189 stride);
6190 }
6191 }
6192 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6193 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6194 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6195 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6196 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6197 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6198 stride);
6199 }
6200 }
sourav parmar83c31b12020-05-06 12:30:54 -07006201 return skip;
6202}
6203bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6204 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6205 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006206 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006207 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6208 skip |= LogError(
6209 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6210 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6211 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006212 }
6213 return skip;
6214}
6215
6216bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006217 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6218 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6219 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6220 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006221 uint32_t width, uint32_t height, uint32_t depth) const {
6222 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006223 // RayGen
6224 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6225 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6226 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006227 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006228 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6229 0) {
6230 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6231 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6232 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6233 }
6234 // Callable
6235 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6236 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6237 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6238 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006239 }
6240 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6241 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6242 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006243 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6244 }
6245 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6246 0) {
6247 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6248 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6249 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006250 }
6251 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006252 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6253 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6254 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6255 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006256 }
6257 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6258 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006259 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6260 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006261 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006262 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6263 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
6264 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6265 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6266 }
sourav parmar83c31b12020-05-06 12:30:54 -07006267 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006268 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6269 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
6270 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
6271 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07006272 }
6273 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6274 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
6275 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006276 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6277 }
6278 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6279 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
6280 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6281 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6282 }
6283 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
6284 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
6285 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
6286 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
6287 }
6288 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6289 skip |=
6290 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6291 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6292 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006293 }
6294
sourav parmarcd5fb182020-07-17 12:58:44 -07006295 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6296 skip |=
6297 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6298 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6299 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6300 }
6301
6302 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6303 skip |=
6304 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6305 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6306 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006307 }
6308 return skip;
6309}
6310
sourav parmarcd5fb182020-07-17 12:58:44 -07006311bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6312 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6313 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6314 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006315 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006316 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006317 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6318 skip |= LogError(
6319 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6320 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6321 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006322 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006323 // RayGen
6324 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6325 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6326 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006327 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006328 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6329 0) {
6330 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6331 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6332 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6333 }
6334 // Callabe
6335 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6336 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6337 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6338 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006339 }
6340 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6341 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006342 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6343 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6344 }
6345 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6346 0) {
6347 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6348 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6349 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006350 }
6351 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006352 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6353 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6354 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6355 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006356 }
6357 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6358 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006359 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6360 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006361 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006362 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6363 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6364 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6365 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6366 }
sourav parmar83c31b12020-05-06 12:30:54 -07006367 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006368 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6369 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6370 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6371 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006372 }
6373 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6374 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006375 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6376 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6377 }
6378 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6379 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6380 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6381 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006382 }
6383
sourav parmarcd5fb182020-07-17 12:58:44 -07006384 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
6385 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
6386 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07006387 }
6388 return skip;
6389}
6390bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
6391 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
6392 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
6393 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
6394 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
6395 uint32_t width, uint32_t height, uint32_t depth) const {
6396 bool skip = false;
6397 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6398 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
6399 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
6400 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6401 }
6402 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6403 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
6404 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
6405 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6406 }
6407 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6408 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
6409 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
6410 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
6411 }
6412
6413 // hitShader
6414 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6415 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
6416 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
6417 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6418 }
6419 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6420 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
6421 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
6422 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6423 }
6424 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6425 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
6426 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
6427 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6428 }
6429
6430 // missShader
6431 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6432 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
6433 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
6434 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6435 }
6436 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6437 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
6438 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
6439 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6440 }
6441 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6442 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
6443 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
6444 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6445 }
6446
6447 // raygenShader
6448 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6449 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
6450 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07006451 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6452 }
6453 if (width > device_limits.maxComputeWorkGroupCount[0]) {
6454 skip |=
6455 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
6456 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
6457 }
6458 if (height > device_limits.maxComputeWorkGroupCount[1]) {
6459 skip |=
6460 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
6461 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
6462 }
6463 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
6464 skip |=
6465 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
6466 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07006467 }
6468 return skip;
6469}
6470
sourav parmar83c31b12020-05-06 12:30:54 -07006471bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006472 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
6473 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006474 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006475 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6476 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006477 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
6478 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006479 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07006480 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
6481 }
6482 return skip;
6483}
6484
Piers Daniell39842ee2020-07-10 16:42:33 -06006485bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
6486 const VkViewport *pViewports) const {
6487 bool skip = false;
6488
6489 if (!physical_device_features.multiViewport) {
6490 if (viewportCount != 1) {
6491 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
6492 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
6493 ") is not 1.",
6494 viewportCount);
6495 }
6496 } else { // multiViewport enabled
6497 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
6498 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
6499 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
6500 ") must "
6501 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6502 viewportCount, device_limits.maxViewports);
6503 }
6504 }
6505
6506 if (pViewports) {
6507 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
6508 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
6509 const char *fn_name = "vkCmdSetViewportWithCountEXT";
6510 skip |= manual_PreCallValidateViewport(
6511 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
6512 }
6513 }
6514
6515 return skip;
6516}
6517
6518bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
6519 const VkRect2D *pScissors) const {
6520 bool skip = false;
6521
6522 if (!physical_device_features.multiViewport) {
6523 if (scissorCount != 1) {
6524 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
6525 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6526 ") must "
6527 "be 1 when the multiViewport feature is disabled.",
6528 scissorCount);
6529 }
6530 } else { // multiViewport enabled
6531 if (scissorCount == 0) {
6532 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6533 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6534 ") must "
6535 "be great than zero.",
6536 scissorCount);
6537 } else if (scissorCount > device_limits.maxViewports) {
6538 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6539 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6540 ") must "
6541 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6542 scissorCount, device_limits.maxViewports);
6543 }
6544 }
6545
6546 if (pScissors) {
6547 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
6548 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
6549
6550 if (scissor.offset.x < 0) {
6551 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6552 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
6553 scissor.offset.x);
6554 }
6555
6556 if (scissor.offset.y < 0) {
6557 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6558 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
6559 scissor.offset.y);
6560 }
6561
6562 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
6563 if (x_sum > INT32_MAX) {
6564 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
6565 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6566 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6567 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
6568 }
6569
6570 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
6571 if (y_sum > INT32_MAX) {
6572 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
6573 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6574 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6575 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
6576 }
6577 }
6578 }
6579
6580 return skip;
6581}
6582
6583bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6584 uint32_t bindingCount, const VkBuffer *pBuffers,
6585 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
6586 const VkDeviceSize *pStrides) const {
6587 bool skip = false;
6588 if (firstBinding >= device_limits.maxVertexInputBindings) {
6589 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
6590 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
6591 firstBinding, device_limits.maxVertexInputBindings);
6592 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6593 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
6594 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
6595 "maxVertexInputBindings (%u)",
6596 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6597 }
6598
6599 for (uint32_t i = 0; i < bindingCount; ++i) {
6600 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006601 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06006602 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
6603 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
6604 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
6605 } else {
6606 if (pOffsets[i] != 0) {
6607 skip |=
6608 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
6609 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
6610 }
6611 }
6612 }
6613 if (pStrides) {
6614 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
6615 skip |=
6616 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006617 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%u)", i,
Piers Daniell39842ee2020-07-10 16:42:33 -06006618 pStrides[i], device_limits.maxVertexInputBindingStride);
6619 }
6620 }
6621 }
6622
6623 return skip;
6624}
sourav parmarcd5fb182020-07-17 12:58:44 -07006625
6626bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6627 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6628 bool skip = false;
6629 for (uint32_t i = 0; i < infoCount; ++i) {
6630 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6631 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6632 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6633 }
6634 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6635 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6636 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6637 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6638 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6639 api_name);
6640 }
6641 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6642 skip |=
6643 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6644 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6645 }
6646 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6647 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6648 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6649 }
6650 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6651 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6652 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6653 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6654 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6655 api_name);
6656 }
6657 if (pInfos[i].pGeometries) {
6658 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6659 skip |= validate_ranged_enum(
6660 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6661 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6662 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6663 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006664 skip |= validate_struct_type(
6665 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6666 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6667 &(pInfos[i].pGeometries[j].geometry.triangles),
6668 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6669 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6670 skip |= validate_struct_pnext(
6671 api_name,
6672 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6673 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6674 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6675 skip |=
6676 validate_ranged_enum(api_name,
6677 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6678 ParameterName::IndexVector{i, j}),
6679 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6680 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6681 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6682 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6683 &pInfos[i].pGeometries[j].geometry.triangles,
6684 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6685 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6686 skip |= validate_ranged_enum(
6687 api_name,
6688 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6689 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6690 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6691
6692 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6693 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6694 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6695 }
6696 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6697 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6698 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6699 skip |=
6700 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6701 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6702 api_name);
6703 }
6704 }
6705 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6706 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6707 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6708 &pInfos[i].pGeometries[j].geometry.instances,
6709 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6710 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6711 skip |= validate_struct_type(
6712 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6713 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6714 &(pInfos[i].pGeometries[j].geometry.instances),
6715 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6716 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6717 skip |= validate_struct_pnext(
6718 api_name,
6719 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6720 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6721 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6722
6723 skip |= validate_bool32(api_name,
6724 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6725 ParameterName::IndexVector{i, j}),
6726 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6727 }
6728 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6729 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6730 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6731 &pInfos[i].pGeometries[j].geometry.aabbs,
6732 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6733 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6734 skip |= validate_struct_type(
6735 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6736 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6737 &(pInfos[i].pGeometries[j].geometry.aabbs),
6738 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6739 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6740 skip |= validate_struct_pnext(
6741 api_name,
6742 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6743 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6744 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6745 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6746 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6747 "(%s):stride must be less than or equal to 2^32-1", api_name);
6748 }
6749 }
6750 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6751 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6752 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6753 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6754 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6755 api_name);
6756 }
6757 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6758 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6759 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6760 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6761 "of elements of"
6762 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6763 api_name);
6764 }
6765 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6766 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6767 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6768 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6769 api_name);
6770 }
6771 }
6772 }
6773 }
6774 if (pInfos[i].ppGeometries != NULL) {
6775 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6776 skip |= validate_ranged_enum(
6777 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6778 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6779 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6780 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006781 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6782 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6783 &pInfos[i].ppGeometries[j]->geometry.triangles,
6784 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6785 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6786 skip |= validate_struct_type(
6787 api_name,
6788 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6789 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6790 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6791 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6792 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6793 skip |= validate_struct_pnext(
6794 api_name,
6795 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6796 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6797 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6798 skip |= validate_ranged_enum(api_name,
6799 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6800 ParameterName::IndexVector{i, j}),
6801 "VkFormat", AllVkFormatEnums,
6802 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6803 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6804 skip |= validate_ranged_enum(api_name,
6805 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6806 ParameterName::IndexVector{i, j}),
6807 "VkIndexType", AllVkIndexTypeEnums,
6808 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6809 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6810 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6811 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6812 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6813 }
6814 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6815 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6816 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6817 skip |=
6818 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6819 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6820 api_name);
6821 }
6822 }
6823 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6824 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6825 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6826 &pInfos[i].ppGeometries[j]->geometry.instances,
6827 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6828 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6829 skip |= validate_struct_type(
6830 api_name,
6831 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6832 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6833 &(pInfos[i].ppGeometries[j]->geometry.instances),
6834 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6835 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6836 skip |= validate_struct_pnext(
6837 api_name,
6838 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6839 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6840 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6841 skip |= validate_bool32(api_name,
6842 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6843 ParameterName::IndexVector{i, j}),
6844 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6845 }
6846 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6847 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6848 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6849 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6850 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6851 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6852 skip |= validate_struct_type(
6853 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6854 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6855 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6856 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6857 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6858 skip |= validate_struct_pnext(
6859 api_name,
6860 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6861 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6862 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6863 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6864 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6865 "(%s):stride must be less than or equal to 2^32-1", api_name);
6866 }
6867 }
6868 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6869 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6870 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6871 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6872 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6873 api_name);
6874 }
6875 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6876 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6877 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6878 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6879 "of elements of"
6880 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6881 api_name);
6882 }
6883 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6884 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6885 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6886 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6887 api_name);
6888 }
6889 }
6890 }
6891 }
6892 }
6893 return skip;
6894}
6895bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6896 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6897 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6898 bool skip = false;
6899 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6900 for (uint32_t i = 0; i < infoCount; ++i) {
6901 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6902 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6903 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6904 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6905 "scratchData.deviceAddress member must be a multiple of "
6906 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6907 }
6908 for (uint32_t k = 0; k < infoCount; ++k) {
6909 if (i == k) continue;
6910 bool found = false;
6911 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6912 skip |= LogError(
6913 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6914 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6915 "not be "
6916 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6917 i, k);
6918 found = true;
6919 }
6920 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6921 skip |= LogError(
6922 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
6923 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
6924 "not be "
6925 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6926 i, k);
6927 found = true;
6928 }
6929 if (found) break;
6930 }
6931 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6932 if (pInfos[i].pGeometries) {
6933 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6934 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6935 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6936 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6937 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6938 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6939 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6940 }
6941 } else {
6942 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6943 skip |=
6944 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6945 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6946 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6947 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6948 }
6949 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006950 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006951 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6952 skip |= LogError(
6953 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6954 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6955 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6956 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006957 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6958 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006959 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6960 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6961 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6962 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6963 }
6964 }
6965 } else if (pInfos[i].ppGeometries) {
6966 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6967 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6968 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6969 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6970 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6971 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6972 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6973 }
6974 } else {
6975 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6976 skip |=
6977 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6978 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6979 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6980 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6981 }
6982 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006983 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006984 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6985 skip |= LogError(
6986 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6987 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6988 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6989 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006990 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6991 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006992 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6993 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6994 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6995 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6996 }
6997 }
6998 }
6999 }
7000 }
7001 return skip;
7002}
7003
7004bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7005 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7006 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7007 const uint32_t *const *ppMaxPrimitiveCounts) const {
7008 bool skip = false;
7009 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7010 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007011 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007012 if (!ray_tracing_acceleration_structure_features ||
7013 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7014 skip |= LogError(
7015 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
7016 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
7017 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
7018 }
7019 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007020 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7021 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7022 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
7023 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
7024 "scratchData.deviceAddress member must be a multiple of "
7025 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7026 }
7027 for (uint32_t k = 0; k < infoCount; ++k) {
7028 if (i == k) continue;
7029 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
7030 skip |=
7031 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
7032 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
7033 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
7034 "any other element [%d) of pInfos.",
7035 i, k);
7036 break;
7037 }
7038 }
7039 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7040 if (pInfos[i].pGeometries) {
7041 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7042 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7043 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7044 skip |= LogError(
7045 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7046 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7047 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7048 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7049 }
7050 } else {
7051 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7052 skip |= LogError(
7053 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7054 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7055 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7056 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7057 }
7058 }
7059 }
7060 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7061 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7062 skip |= LogError(
7063 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7064 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7065 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7066 }
7067 }
7068 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7069 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7070 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7071 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7072 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7073 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7074 }
7075 }
7076 } else if (pInfos[i].ppGeometries) {
7077 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7078 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7079 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7080 skip |= LogError(
7081 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7082 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7083 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7084 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7085 }
7086 } else {
7087 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7088 skip |= LogError(
7089 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7090 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7091 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7092 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7093 }
7094 }
7095 }
7096 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7097 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7098 skip |= LogError(
7099 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7100 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7101 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7102 }
7103 }
7104 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7105 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7106 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7107 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7108 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7109 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7110 }
7111 }
7112 }
7113 }
7114 }
7115 return skip;
7116}
7117
7118bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7119 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7120 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7121 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7122 bool skip = false;
7123 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7124 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007125 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007126 if (!ray_tracing_acceleration_structure_features ||
7127 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7128 skip |=
7129 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7130 "vkBuildAccelerationStructuresKHR: The "
7131 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7132 }
7133 for (uint32_t i = 0; i < infoCount; ++i) {
7134 for (uint32_t j = 0; j < infoCount; ++j) {
7135 if (i == j) continue;
7136 bool found = false;
7137 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7138 skip |= LogError(
7139 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7140 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
7141 "not be "
7142 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7143 i, j);
7144 found = true;
7145 }
7146 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7147 skip |= LogError(
7148 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7149 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
7150 "not be "
7151 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7152 i, j);
7153 found = true;
7154 }
7155 if (found) break;
7156 }
7157 }
7158 return skip;
7159}
7160
7161bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7162 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7163 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7164 bool skip = false;
7165 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7166 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007167 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7168 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007169 if (!(ray_tracing_pipeline_features || ray_query_features) ||
7170 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
7171 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
7172 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
7173 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
7174 }
7175 return skip;
7176}
sfricke-samsungecafb192021-01-17 08:21:14 -08007177
7178bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
7179 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
7180 const VkAllocationCallbacks *pAllocator,
7181 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
7182 bool skip = false;
7183 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
7184 if (private_data_features && private_data_features->privateData == VK_FALSE) {
7185 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
7186 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
7187 }
7188 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07007189}
Piers Daniellcb6d8032021-04-19 18:51:26 -06007190
7191bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7192 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7193 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7194 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7195 bool skip = false;
7196 const auto *vertex_input_dynamic_state_features =
7197 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
7198 const auto *vertex_attribute_divisor_features =
7199 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7200
7201 // VUID-vkCmdSetVertexInputEXT-None-04790
7202 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
7203 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
7204 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
7205 }
7206
7207 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7208 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7209 skip |=
7210 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7211 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7212 }
7213
7214 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7215 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7216 skip |= LogError(
7217 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7218 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7219 }
7220
7221 // VUID-vkCmdSetVertexInputEXT-binding-04793
7222 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7223 bool binding_found = false;
7224 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7225 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
7226 binding_found = true;
7227 break;
7228 }
7229 }
7230 if (!binding_found) {
7231 skip |=
7232 LogError(device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
7233 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u] references an unspecified binding", attribute);
7234 }
7235 }
7236
7237 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
7238 if (vertexBindingDescriptionCount > 1) {
7239 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
7240 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
7241 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
7242 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
7243 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
7244 "vkCmdSetVertexInputEXT(): binding description for binding %u already specified", binding_value);
7245 }
7246 }
7247 }
7248 }
7249
7250 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
7251 if (vertexAttributeDescriptionCount > 1) {
7252 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
7253 uint32_t location = pVertexAttributeDescriptions[attribute].location;
7254 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
7255 if (location == pVertexAttributeDescriptions[next_attribute].location) {
7256 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
7257 "vkCmdSetVertexInputEXT(): attribute description for location %u already specified", location);
7258 }
7259 }
7260 }
7261 }
7262
7263 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7264 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
7265 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
7266 skip |= LogError(
7267 device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
7268 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].binding is greater than maxVertexInputBindings", binding);
7269 }
7270
7271 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
7272 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
7273 skip |= LogError(
7274 device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
7275 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].stride is greater than maxVertexInputBindingStride",
7276 binding);
7277 }
7278
7279 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
7280 if (pVertexBindingDescriptions[binding].divisor == 0 &&
7281 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
7282 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
7283 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is zero but "
7284 "vertexAttributeInstanceRateZeroDivisor is not enabled",
7285 binding);
7286 }
7287
7288 if (pVertexBindingDescriptions[binding].divisor > 1) {
7289 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7290 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7291 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
7292 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than one but "
7293 "vertexAttributeInstanceRateDivisor is not enabled",
7294 binding);
7295 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007296 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06007297 if (pVertexBindingDescriptions[binding].divisor >
7298 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
7299 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007300 device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007301 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than maxVertexAttribDivisor",
7302 binding);
7303 }
7304
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007305 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06007306 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
7307 skip |=
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007308 LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007309 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than 1 but inputRate "
7310 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7311 binding);
7312 }
7313 }
7314 }
7315 }
7316
7317 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007318 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06007319 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
7320 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007321 device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007322 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].location is greater than maxVertexInputAttributes",
7323 attribute);
7324 }
7325
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007326 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06007327 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
7328 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007329 device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007330 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].binding is greater than maxVertexInputBindings",
7331 attribute);
7332 }
7333
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007334 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06007335 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
7336 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007337 device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007338 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].offset is greater than maxVertexInputAttributeOffset",
7339 attribute);
7340 }
7341
7342 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7343 VkFormatProperties properties;
7344 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7345 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7346 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
7347 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].format is not a "
7348 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7349 attribute);
7350 }
7351 }
7352
7353 return skip;
7354}
sfricke-samsung51303fb2021-05-09 19:09:13 -07007355
7356bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
7357 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
7358 const void *pValues) const {
7359 bool skip = false;
7360 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
7361 // Check that offset + size don't exceed the max.
7362 // Prevent arithetic overflow here by avoiding addition and testing in this order.
7363 if (offset >= max_push_constants_size) {
7364 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00370",
7365 "vkCmdPushConstants(): offset (%u) that exceeds this device's maxPushConstantSize of %u.", offset,
7366 max_push_constants_size);
7367 }
7368 if (size > max_push_constants_size - offset) {
7369 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
7370 "vkCmdPushConstants(): offset (%u) and size (%u) that exceeds this device's maxPushConstantSize of %u.",
7371 offset, size, max_push_constants_size);
7372 }
7373
7374 // size needs to be non-zero and a multiple of 4.
7375 if (size & 0x3) {
7376 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369", "vkCmdPushConstants(): size (%u) must be a multiple of 4.",
7377 size);
7378 }
7379
7380 // offset needs to be a multiple of 4.
7381 if ((offset & 0x3) != 0) {
7382 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007383 "vkCmdPushConstants(): offset (%u) must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007384 }
7385 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007386}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02007387
7388bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
7389 uint32_t srcCacheCount,
7390 const VkPipelineCache *pSrcCaches) const {
7391 bool skip = false;
7392 if (pSrcCaches) {
7393 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
7394 if (pSrcCaches[index0] == dstCache) {
7395 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
7396 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
7397 report_data->FormatHandle(dstCache).c_str());
7398 break;
7399 }
7400 }
7401 }
7402 return skip;
7403}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06007404
7405bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
7406 VkImageLayout imageLayout, const VkClearColorValue *pColor,
7407 uint32_t rangeCount,
7408 const VkImageSubresourceRange *pRanges) const {
7409 bool skip = false;
7410 if (!pColor) {
7411 skip |=
7412 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
7413 }
7414 return skip;
7415}
7416
7417bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
7418 const VkRenderPassBeginInfo *const rp_begin) const {
7419 bool skip = false;
7420 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
7421 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
7422 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
7423 "), but VkRenderPassBeginInfo::pClearValues is not null.",
7424 func_name, rp_begin->clearValueCount);
7425 }
7426 return skip;
7427}
7428
7429bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7430 VkSubpassContents) const {
7431 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
7432 return skip;
7433}
7434
7435bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
7436 const VkRenderPassBeginInfo *pRenderPassBegin,
7437 const VkSubpassBeginInfo *) const {
7438 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
7439 return skip;
7440}
7441
7442bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7443 const VkSubpassBeginInfo *) const {
7444 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
7445 return skip;
7446}