blob: 835427d7bd7050387eddf32ff0a4b669dd8aa870 [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[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02002916 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
2917 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002918
Petr Krause91f7a12017-12-14 20:57:36 +01002919 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002920 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2921 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2922 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2923 pCreateInfos[i].pColorBlendState,
2924 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2925 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2926
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002927 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002928 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002929 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
ziga-lunarg8de09162021-08-05 15:21:33 +02002930 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002931 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
2932 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002933 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2934 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002935
2936 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002937 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002938 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002939 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002940
2941 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002942 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002943 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2944 pCreateInfos[i].pColorBlendState->logicOpEnable);
2945
2946 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002947 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002948 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2949 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002950 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002951 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002952
2953 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002954 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
2955 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002956 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002957 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002958 ParameterName::IndexVector{i, attachment_index}),
2959 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002960
2961 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002962 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002963 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002964 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002965 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002966 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002967 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002968
2969 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002970 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002971 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002972 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002973 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002974 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002975 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002976
2977 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002978 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002979 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002980 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002981 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002982 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002983 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002984
2985 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002986 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002987 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002988 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002989 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002990 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002991 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002992
2993 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002994 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002995 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002996 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002997 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002998 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002999 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003000
3001 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003002 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003003 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003004 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003005 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003006 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003007 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003008
3009 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003010 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003011 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003012 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003013 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003014 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003015 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003016
3017 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3018 bool invalid = false;
3019 switch (pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
3020 case VK_BLEND_OP_ZERO_EXT:
3021 case VK_BLEND_OP_SRC_EXT:
3022 case VK_BLEND_OP_DST_EXT:
3023 case VK_BLEND_OP_SRC_OVER_EXT:
3024 case VK_BLEND_OP_DST_OVER_EXT:
3025 case VK_BLEND_OP_SRC_IN_EXT:
3026 case VK_BLEND_OP_DST_IN_EXT:
3027 case VK_BLEND_OP_SRC_OUT_EXT:
3028 case VK_BLEND_OP_DST_OUT_EXT:
3029 case VK_BLEND_OP_SRC_ATOP_EXT:
3030 case VK_BLEND_OP_DST_ATOP_EXT:
3031 case VK_BLEND_OP_XOR_EXT:
3032 case VK_BLEND_OP_INVERT_EXT:
3033 case VK_BLEND_OP_INVERT_RGB_EXT:
3034 case VK_BLEND_OP_LINEARDODGE_EXT:
3035 case VK_BLEND_OP_LINEARBURN_EXT:
3036 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3037 case VK_BLEND_OP_LINEARLIGHT_EXT:
3038 case VK_BLEND_OP_PINLIGHT_EXT:
3039 case VK_BLEND_OP_HARDMIX_EXT:
3040 case VK_BLEND_OP_PLUS_EXT:
3041 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3042 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3043 case VK_BLEND_OP_PLUS_DARKER_EXT:
3044 case VK_BLEND_OP_MINUS_EXT:
3045 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3046 case VK_BLEND_OP_CONTRAST_EXT:
3047 case VK_BLEND_OP_INVERT_OVG_EXT:
3048 case VK_BLEND_OP_RED_EXT:
3049 case VK_BLEND_OP_GREEN_EXT:
3050 case VK_BLEND_OP_BLUE_EXT:
3051 invalid = true;
3052 break;
3053 default:
3054 break;
3055 }
3056 if (invalid) {
3057 skip |= LogError(
3058 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3059 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3060 "].pColorBlendState->pAttachments[%" PRIu32
3061 "].colorBlendOp (%s) is not valid when "
3062 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3063 "VK_FALSE",
3064 i, attachment_index,
3065 string_VkBlendOp(
3066 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp));
3067 }
3068 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003069 }
3070 }
3071
3072 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003073 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003074 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
3075 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3076 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003077 }
3078
3079 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
3080 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
3081 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003082 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003083 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06003084 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
3085 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003086 }
3087 }
3088 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003089
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003090 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3091 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01003092 if (pCreateInfos[i].basePipelineIndex != -1) {
3093 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003094 skip |=
3095 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003096 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003097 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003098 "and pCreateInfos->basePipelineIndex is not -1.",
3099 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003100 }
3101 }
3102
Petr Kraus9752aae2017-11-24 03:05:50 +01003103 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3104 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003105 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003106 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003107 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003108 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3109 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003110 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003111 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07003112 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003113 skip |=
3114 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
3115 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
3116 "index into the pCreateInfos array, of size %d.",
3117 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003118 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003119 }
3120 }
3121
Petr Kraus9752aae2017-11-24 03:05:50 +01003122 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003123 if (!device_extensions.vk_nv_fill_rectangle) {
3124 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
3125 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003126 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3127 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3128 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3129 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02003130 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3131 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003132 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003133 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003134 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
3135 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3136 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003137 }
3138 } else {
3139 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3140 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
3141 (physical_device_features.fillModeNonSolid == false)) {
3142 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003143 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3144 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003145 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
3146 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3147 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003148 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003149 }
Petr Kraus299ba622017-11-24 03:09:03 +01003150
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003151 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01003152 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003153 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3154 "The line width state is static (pCreateInfos[%" PRIu32
3155 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3156 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3157 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
3158 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003159 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003160 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003161
3162 // Validate no flags not allowed are used
3163 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003164 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
3165 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3166 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3167 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003168 }
3169 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003170 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
3171 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3172 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3173 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003174 }
3175 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3176 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsungad008902021-04-16 01:25:34 -07003177 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3178 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3179 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003180 }
3181 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3182 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsungad008902021-04-16 01:25:34 -07003183 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3184 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3185 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003186 }
3187 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3188 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsungad008902021-04-16 01:25:34 -07003189 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3190 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3191 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003192 }
3193 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3194 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsungad008902021-04-16 01:25:34 -07003195 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3196 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3197 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003198 }
3199 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3200 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsungad008902021-04-16 01:25:34 -07003201 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3202 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3203 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003204 }
3205 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3206 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsungad008902021-04-16 01:25:34 -07003207 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3208 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3209 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003210 }
3211 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3212 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsungad008902021-04-16 01:25:34 -07003213 "vkCreateGraphicsPipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3214 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3215 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003216 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003217 }
3218 }
3219
3220 return skip;
3221}
3222
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003223bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3224 uint32_t createInfoCount,
3225 const VkComputePipelineCreateInfo *pCreateInfos,
3226 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003227 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003228 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003229 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003230 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003231 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003232 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003233 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003234 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003235 skip |=
3236 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
3237 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3238 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3239 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003240 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003241
3242 // Make sure compute stage is selected
3243 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003244 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
3245 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
3246 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003247 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003248
sfricke-samsungeb549012021-04-16 01:25:51 -07003249 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3250 // Validate no flags not allowed are used
3251 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
3252 skip |= LogError(
3253 device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3254 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3255 i, flags);
3256 }
3257 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3258 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
3259 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3260 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3261 i, flags);
3262 }
3263 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3264 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
3265 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3266 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3267 i, flags);
3268 }
3269 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3270 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
3271 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3272 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3273 i, flags);
3274 }
3275 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3276 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
3277 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3278 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3279 i, flags);
3280 }
3281 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3282 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
3283 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3284 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3285 i, flags);
3286 }
3287 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3288 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
3289 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3290 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3291 i, flags);
3292 }
3293 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3294 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
3295 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3296 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3297 i, flags);
3298 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003299 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3300 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
3301 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3302 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3303 i, flags);
3304 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003305 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3306 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
3307 "vkCreateComputePipelines(): pCreateInfos[%u]->flags (0x%x) must not include "
3308 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3309 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003310 }
ziga-lunargc6341372021-07-28 12:57:42 +02003311
3312 std::stringstream msg;
3313 msg << "pCreateInfos[%" << i << "].stage";
3314 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003315 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003316 return skip;
3317}
3318
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003319bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003320 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003321 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003322
3323 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003324 const auto &features = physical_device_features;
3325 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003326
John Zulauf71968502017-10-26 13:51:15 -06003327 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3328 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003329 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3330 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3331 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3332 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003333 }
3334
3335 // Anistropy cannot be enabled in sampler unless enabled as a feature
3336 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003337 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3338 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3339 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003340 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003341 }
John Zulauf71968502017-10-26 13:51:15 -06003342
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003343 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3344 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003345 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3346 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3347 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3348 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003349 }
3350 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003351 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3352 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3353 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3354 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003355 }
3356 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003357 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3358 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3359 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3360 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003361 }
3362 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3363 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3364 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3365 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003366 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3367 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3368 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3369 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3370 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3371 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003372 }
3373 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003374 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3375 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3376 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003377 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003378 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003379 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3380 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3381 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003382 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003383 }
3384
3385 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3386 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003387 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3388 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003389 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003390 if (sampler_reduction != nullptr) {
3391 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3392 skip |= LogError(
3393 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3394 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3395 }
3396 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003397 }
3398
3399 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3400 // valid VkBorderColor value
3401 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3402 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3403 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003404 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3405 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003406 }
3407
John Zulauf275805c2017-10-26 15:34:49 -06003408 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003409 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06003410 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3411 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003412 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3413 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3414 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003415 }
3416 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003417
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003418 // Check for valid Lod range
3419 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003420 skip |=
3421 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3422 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003423 }
3424
3425 // Check mipLodBias to device limit
3426 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003427 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3428 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3429 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003430 }
3431
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003432 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003433 if (sampler_conversion != nullptr) {
3434 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3435 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3436 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3437 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003438 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003439 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003440 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3441 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3442 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3443 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3444 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3445 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3446 }
3447 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003448
3449 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3450 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3451 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3452 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3453 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3454 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3455 }
3456 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3457 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3458 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3459 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3460 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3461 }
3462 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3463 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3464 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3465 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3466 pCreateInfo->minLod, pCreateInfo->maxLod);
3467 }
3468 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3469 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3470 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3471 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3472 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3473 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3474 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3475 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3476 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3477 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3478 }
3479 if (pCreateInfo->anisotropyEnable) {
3480 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3481 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3482 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3483 }
3484 if (pCreateInfo->compareEnable) {
3485 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3486 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3487 "pCreateInfo->compareEnable must be VK_FALSE");
3488 }
3489 if (pCreateInfo->unnormalizedCoordinates) {
3490 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3491 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3492 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3493 }
3494 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003495 }
3496
Tony-LunarG7337b312020-04-15 16:40:25 -06003497 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3498 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3499 if (!device_extensions.vk_ext_custom_border_color) {
3500 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3501 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3502 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3503 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003504 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
Tony-LunarG7337b312020-04-15 16:40:25 -06003505 if (!custom_create_info) {
3506 skip |=
3507 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3508 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3509 "struct in pNext chain.\n",
3510 string_VkBorderColor(pCreateInfo->borderColor));
3511 } else {
3512 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3513 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
3514 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3515 !FormatIsSampledFloat(custom_create_info->format)))) {
3516 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
3517 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3518 "whose type does not match\n",
3519 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
3520 ;
3521 }
3522 }
3523 }
3524
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003525 return skip;
3526}
3527
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003528bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3529 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3530 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003531 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003532 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003533
3534 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3535 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3536 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3537 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003538 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3539 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3540 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3541 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3542 ++descriptor_index) {
3543 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003544 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003545 "vkCreateDescriptorSetLayout: required parameter "
3546 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3547 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003548 }
3549 }
3550 }
3551
3552 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3553 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3554 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003555 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3556 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3557 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3558 "values.",
3559 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003560 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003561
3562 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3563 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3564 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3565 skip |=
3566 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3567 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3568 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3569 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3570 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3571 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003572 }
3573 }
3574 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003575 return skip;
3576}
3577
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003578bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3579 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003580 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003581 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3582 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3583 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003584 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3585 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003586}
3587
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003588bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3589 const VkWriteDescriptorSet *pDescriptorWrites,
3590 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003591 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003592
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003593 if (pDescriptorWrites != NULL) {
3594 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3595 // descriptorCount must be greater than 0
3596 if (pDescriptorWrites[i].descriptorCount == 0) {
3597 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003598 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3599 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003600 }
3601
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003602 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3603 if (validateDstSet) {
3604 // dstSet must be a valid VkDescriptorSet handle
3605 skip |= validate_required_handle(vkCallingFunction,
3606 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3607 pDescriptorWrites[i].dstSet);
3608 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003609
3610 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3611 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3612 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3613 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3614 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3615 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3616 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003617 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3618 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003619 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003620 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3621 "%s(): if pDescriptorWrites[%d].descriptorType is "
3622 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3623 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3624 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3625 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003626 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3627 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003628 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3629 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003630 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3631 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003632 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003633 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3634 ParameterName::IndexVector{i, descriptor_index}),
3635 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003636 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003637 }
3638 }
3639 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3640 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3641 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3642 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3643 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3644 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3645 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003646 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003647 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003648 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3649 "%s(): if pDescriptorWrites[%d].descriptorType is "
3650 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3651 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3652 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3653 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003654 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003655 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003656 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003657 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003658 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3659 ++descriptor_index) {
3660 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3661 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3662 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003663 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3664 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003665 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003666 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3667 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003668 }
3669 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003670 }
3671 }
3672 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3673 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003674 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003675 }
3676
3677 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3678 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003679 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003680 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3681 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003682 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003683 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003684 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3685 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3686 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003687 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003688 }
3689 }
3690 }
3691 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3692 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003693 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003694 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3695 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003696 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003697 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003698 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3699 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3700 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003701 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003702 }
3703 }
3704 }
3705 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003706 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3707 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08003708 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003709 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003710 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3711 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3712 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3713 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3714 "accelerationStructureCount %d member equals descriptorCount %d.",
3715 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3716 pDescriptorWrites[i].descriptorCount);
3717 }
3718 // further checks only if we have right structtype
3719 if (pnext_struct) {
3720 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3721 skip |= LogError(
3722 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3723 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3724 ".",
3725 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003726 }
sourav parmarbcee7512020-12-28 14:34:49 -08003727 if (pnext_struct->accelerationStructureCount == 0) {
3728 skip |= LogError(device,
3729 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003730 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003731 }
3732 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003733 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003734 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3735 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3736 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3737 skip |= LogError(device,
3738 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
3739 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003740 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003741 }
3742 }
3743 }
sourav parmarbcee7512020-12-28 14:34:49 -08003744 }
3745 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003746 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08003747 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
3748 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
3749 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
3750 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
3751 "accelerationStructureCount %d member equals descriptorCount %d.",
3752 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
3753 pDescriptorWrites[i].descriptorCount);
3754 }
3755 // further checks only if we have right structtype
3756 if (pnext_struct) {
3757 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
3758 skip |= LogError(
3759 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
3760 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3761 ".",
3762 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07003763 }
sourav parmarbcee7512020-12-28 14:34:49 -08003764 if (pnext_struct->accelerationStructureCount == 0) {
3765 skip |= LogError(device,
3766 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003767 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08003768 }
3769 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003770 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08003771 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
3772 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
3773 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
3774 skip |= LogError(device,
3775 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
3776 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06003777 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07003778 }
3779 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003780 }
3781 }
3782 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003783 }
3784 }
3785 return skip;
3786}
3787
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003788bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3789 const VkWriteDescriptorSet *pDescriptorWrites,
3790 uint32_t descriptorCopyCount,
3791 const VkCopyDescriptorSet *pDescriptorCopies) const {
3792 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3793}
3794
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003795bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003796 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003797 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003798 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3799}
3800
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003801bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3802 const VkAllocationCallbacks *pAllocator,
3803 VkRenderPass *pRenderPass) const {
3804 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3805}
3806
Mike Schuchardt2df08912020-12-15 16:28:09 -08003807bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003808 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003809 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003810 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3811}
3812
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003813bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3814 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003815 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003816 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003817
3818 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3819 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3820 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003821 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3822 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003823 return skip;
3824}
3825
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003826bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003827 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003828 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003829
3830 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3831 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07003832 bool cb_is_secondary;
3833 {
3834 auto lock = cb_read_lock();
3835 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
3836 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003837
Tony-LunarG3c287f62020-12-17 12:39:49 -07003838 if (cb_is_secondary) {
3839 // Implicit VUs
3840 // validate only sType here; pointer has to be validated in core_validation
3841 const bool k_not_required = false;
3842 const char *k_no_vuid = nullptr;
3843 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
3844 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003845 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
3846 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003847
Tony-LunarG3c287f62020-12-17 12:39:49 -07003848 if (info) {
3849 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07003850 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
3851 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07003852 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003853 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
3854 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
3855 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
3856 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003857
Tony-LunarG3c287f62020-12-17 12:39:49 -07003858 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003859
Tony-LunarG3c287f62020-12-17 12:39:49 -07003860 // Explicit VUs
3861 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003862 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07003863 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
3864 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3865 cmd_name);
3866 }
3867
3868 if (physical_device_features.inheritedQueries) {
3869 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003870 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
3871 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
3872 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07003873 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003874 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003875 }
3876
3877 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003878 skip |=
3879 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
3880 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
3881 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
3882 } else { // !pipelineStatisticsQuery
3883 skip |=
3884 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
3885 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07003886 }
3887
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003888 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003889 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003890 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07003891 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3892 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
3893 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003894 commandBuffer,
3895 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07003896 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3897 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3898 }
Petr Kraus139757b2019-08-15 17:19:33 +02003899 }
ziga-lunarg9d019132021-07-19 01:05:31 +02003900
3901 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
3902 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
3903 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
3904 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
3905 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
3906 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
3907 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
3908 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
3909 }
Petr Kraus139757b2019-08-15 17:19:33 +02003910 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003911 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003912 return skip;
3913}
3914
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003915bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003916 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003917 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003918
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003919 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003920 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003921 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3922 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3923 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003924 }
3925 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003926 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3927 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3928 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003929 }
3930 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003931 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003932 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003933 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3934 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3935 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3936 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003937 }
3938 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003939
3940 if (pViewports) {
3941 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3942 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003943 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003944 skip |= manual_PreCallValidateViewport(
3945 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003946 }
3947 }
3948
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003949 return skip;
3950}
3951
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003952bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003953 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003954 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003955
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003956 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003957 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003958 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3959 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3960 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003961 }
3962 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003963 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3964 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3965 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003966 }
3967 } else { // multiViewport enabled
3968 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003969 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003970 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3971 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3972 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3973 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003974 }
3975 }
3976
Petr Kraus6260f0a2018-02-27 21:15:55 +01003977 if (pScissors) {
3978 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3979 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003980
Petr Kraus6260f0a2018-02-27 21:15:55 +01003981 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003982 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3983 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3984 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003985 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003986
Petr Kraus6260f0a2018-02-27 21:15:55 +01003987 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003988 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3989 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3990 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003991 }
3992
3993 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3994 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003995 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3996 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3997 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3998 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003999 }
4000
4001 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4002 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004003 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4004 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4005 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4006 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004007 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004008 }
4009 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004010
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004011 return skip;
4012}
4013
Jeff Bolz5c801d12019-10-09 10:38:45 -05004014bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004015 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004016
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004017 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004018 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4019 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004020 }
4021
4022 return skip;
4023}
4024
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004025bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004026 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004027 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004028
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004029 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004030 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004031 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
4032 }
4033 if (drawCount > device_limits.maxDrawIndirectCount) {
4034 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004035 "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount,
4036 device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004037 }
4038 return skip;
4039}
4040
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004041bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004042 VkDeviceSize offset, uint32_t drawCount,
4043 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004044 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004045 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004046 skip |= LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4047 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d",
4048 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004049 }
4050 if (drawCount > device_limits.maxDrawIndirectCount) {
4051 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004052 "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4053 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004054 }
4055 return skip;
4056}
4057
sfricke-samsungf692b972020-05-02 08:00:45 -07004058bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4059 VkDeviceSize countBufferOffset, bool khr) const {
4060 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004061 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004062 if (offset & 3) {
4063 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004064 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004065 }
4066
4067 if (countBufferOffset & 3) {
4068 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004069 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004070 countBufferOffset);
4071 }
4072 return skip;
4073}
4074
4075bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4076 VkDeviceSize offset, VkBuffer countBuffer,
4077 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4078 uint32_t stride) const {
4079 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4080}
4081
4082bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4083 VkDeviceSize offset, VkBuffer countBuffer,
4084 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4085 uint32_t stride) const {
4086 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4087}
4088
4089bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4090 VkDeviceSize countBufferOffset, bool khr) const {
4091 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004092 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004093 if (offset & 3) {
4094 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004095 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004096 }
4097
4098 if (countBufferOffset & 3) {
4099 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004100 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004101 countBufferOffset);
4102 }
4103 return skip;
4104}
4105
4106bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4107 VkDeviceSize offset, VkBuffer countBuffer,
4108 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4109 uint32_t stride) const {
4110 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4111}
4112
4113bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4114 VkDeviceSize offset, VkBuffer countBuffer,
4115 VkDeviceSize countBufferOffset,
4116 uint32_t maxDrawCount, uint32_t stride) const {
4117 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4118}
4119
Tony-LunarG4490de42021-06-21 15:49:19 -06004120bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4121 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4122 uint32_t firstInstance, uint32_t stride) const {
4123 bool skip = false;
4124 if (stride & 3) {
4125 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4126 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4127 }
4128 if (drawCount && nullptr == pVertexInfo) {
4129 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4130 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4131 "one or more valid instances of VkMultiDrawInfoEXT structures");
4132 }
4133 return skip;
4134}
4135
4136bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4137 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4138 uint32_t instanceCount, uint32_t firstInstance,
4139 uint32_t stride, const int32_t *pVertexOffset) const {
4140 bool skip = false;
4141 if (stride & 3) {
4142 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4143 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4144 }
4145 if (drawCount && nullptr == pIndexInfo) {
4146 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4147 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4148 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4149 }
4150 return skip;
4151}
4152
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004153bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4154 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004155 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004156 bool skip = false;
4157 for (uint32_t rect = 0; rect < rectCount; rect++) {
4158 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004159 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
4160 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004161 }
sfricke-samsung10867682020-04-25 02:20:39 -07004162 if (pRects[rect].rect.extent.width == 0) {
4163 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
4164 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
4165 }
4166 if (pRects[rect].rect.extent.height == 0) {
4167 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
4168 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
4169 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004170 }
4171 return skip;
4172}
4173
Andrew Fobel3abeb992020-01-20 16:33:22 -05004174bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4175 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4176 VkImageFormatProperties2 *pImageFormatProperties,
4177 const char *apiName) const {
4178 bool skip = false;
4179
4180 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004181 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004182 if (image_stencil_struct != nullptr) {
4183 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4184 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4185 // No flags other than the legal attachment bits may be set
4186 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4187 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004188 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4189 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4190 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4191 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4192 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004193 }
4194 }
4195 }
4196 }
4197
4198 return skip;
4199}
4200
4201bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4202 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4203 VkImageFormatProperties2 *pImageFormatProperties) const {
4204 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4205 "vkGetPhysicalDeviceImageFormatProperties2");
4206}
4207
4208bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4209 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4210 VkImageFormatProperties2 *pImageFormatProperties) const {
4211 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4212 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4213}
4214
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004215bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4216 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4217 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4218 bool skip = false;
4219
4220 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4221 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4222 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4223 }
4224
4225 return skip;
4226}
4227
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004228bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4229 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4230 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4231 bool skip = false;
4232
4233 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4234 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4235 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4236 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4237 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4238 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4239 }
4240
4241 return false;
4242}
4243
sfricke-samsung3999ef62020-02-09 17:05:59 -08004244bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4245 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4246 bool skip = false;
4247
4248 if (pRegions != nullptr) {
4249 for (uint32_t i = 0; i < regionCount; i++) {
4250 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004251 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
4252 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004253 }
4254 }
4255 }
4256 return skip;
4257}
4258
Jeff Leger178b1e52020-10-05 12:22:23 -04004259bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4260 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4261 bool skip = false;
4262
4263 if (pCopyBufferInfo->pRegions != nullptr) {
4264 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4265 if (pCopyBufferInfo->pRegions[i].size == 0) {
4266 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
4267 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
4268 }
4269 }
4270 }
4271 return skip;
4272}
4273
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004274bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004275 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4276 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004277 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004278
4279 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004280 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4281 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4282 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004283 }
4284
4285 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004286 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4287 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4288 "), must be greater than zero and less than or equal to 65536.",
4289 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004290 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004291 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4292 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4293 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004294 }
4295 return skip;
4296}
4297
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004298bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004299 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004300 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004301
4302 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004303 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4304 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4305 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004306 }
4307
4308 if (size != VK_WHOLE_SIZE) {
4309 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004310 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004311 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4312 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004313 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004314 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4315 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004316 }
4317 }
4318 return skip;
4319}
4320
sfricke-samsunga1d00272021-03-10 21:37:41 -08004321bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004322 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004323
4324 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004325 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4326 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4327 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4328 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004329 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004330 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4331 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4332 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004333 }
4334
4335 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4336 // queueFamilyIndexCount uint32_t values
4337 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004338 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004339 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004340 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004341 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4342 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004343 }
4344 }
4345
Dave Houlton413a6782018-05-22 13:01:54 -06004346 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004347 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004348
sfricke-samsunga1d00272021-03-10 21:37:41 -08004349 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4350 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4351 if (format_list_info) {
4352 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4353 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4354 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4355 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
4356 "VkImageFormatListCreateInfo::viewFormatCount (%u) must be 0 or 1 if it is in the pNext chain.",
4357 func_name, viewFormatCount);
4358 }
4359
4360 // Using the first format, compare the rest of the formats against it that they are compatible
4361 for (uint32_t i = 1; i < viewFormatCount; i++) {
4362 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4363 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4364 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4365 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
4366 "VkImageFormatListCreateInfo::pViewFormats[%u] (%s) are not compatible in the pNext chain.",
4367 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4368 string_VkFormat(format_list_info->pViewFormats[i]));
4369 }
4370 }
4371 }
4372
4373 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4374 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4375 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4376 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4377 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4378 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4379 func_name);
4380 } else {
4381 if (format_list_info == nullptr) {
4382 skip |= LogError(
4383 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4384 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4385 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4386 func_name);
4387 } else if (format_list_info->viewFormatCount == 0) {
4388 skip |= LogError(
4389 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4390 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4391 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4392 func_name);
4393 } else {
4394 bool found_base_format = false;
4395 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4396 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4397 found_base_format = true;
4398 break;
4399 }
4400 }
4401 if (!found_base_format) {
4402 skip |=
4403 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4404 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4405 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4406 "pCreateInfo->imageFormat.",
4407 func_name);
4408 }
4409 }
4410 }
4411 }
4412 }
4413 return skip;
4414}
4415
4416bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4417 const VkAllocationCallbacks *pAllocator,
4418 VkSwapchainKHR *pSwapchain) const {
4419 bool skip = false;
4420 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4421 return skip;
4422}
4423
4424bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4425 const VkSwapchainCreateInfoKHR *pCreateInfos,
4426 const VkAllocationCallbacks *pAllocator,
4427 VkSwapchainKHR *pSwapchains) const {
4428 bool skip = false;
4429 if (pCreateInfos) {
4430 for (uint32_t i = 0; i < swapchainCount; i++) {
4431 std::stringstream func_name;
4432 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4433 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4434 }
4435 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004436 return skip;
4437}
4438
Jeff Bolz5c801d12019-10-09 10:38:45 -05004439bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004440 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004441
4442 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004443 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004444 if (present_regions) {
4445 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004446 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004447 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4448 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004449 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004450 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4451 "extension swapchainCount is %i. These values must be equal.",
4452 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004453 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004454 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004455 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4456 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004457 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4458 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4459 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004460 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004461 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004462 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004463 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004464 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004465 }
4466 }
4467
4468 return skip;
4469}
4470
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004471bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4472 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4473 const VkAllocationCallbacks *pAllocator,
4474 VkDisplayModeKHR *pMode) const {
4475 bool skip = false;
4476
4477 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4478 if (display_mode_parameters.visibleRegion.width == 0) {
4479 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4480 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4481 }
4482 if (display_mode_parameters.visibleRegion.height == 0) {
4483 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4484 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4485 }
4486 if (display_mode_parameters.refreshRate == 0) {
4487 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4488 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4489 }
4490
4491 return skip;
4492}
4493
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004494#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004495bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4496 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4497 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004498 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004499 bool skip = false;
4500
4501 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004502 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4503 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004504 }
4505
4506 return skip;
4507}
4508#endif // VK_USE_PLATFORM_WIN32_KHR
4509
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004510bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004511 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004512 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004513 bool skip = false;
4514
4515 if (pCreateInfo) {
4516 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004517 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4518 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004519 }
4520
4521 if (pCreateInfo->pPoolSizes) {
4522 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4523 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004524 skip |= LogError(
4525 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004526 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004527 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004528 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4529 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004530 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4531 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4532 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4533 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4534 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004535 }
Petr Krausc8655be2017-09-27 18:56:51 +02004536 }
4537 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02004538
4539 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
4540 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
4541 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
4542 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
4543 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
4544 }
Petr Krausc8655be2017-09-27 18:56:51 +02004545 }
4546
4547 return skip;
4548}
4549
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004550bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004551 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004552 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004553
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004554 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004555 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004556 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
4557 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4558 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004559 }
4560
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004561 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004562 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004563 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
4564 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4565 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004566 }
4567
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004568 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004569 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004570 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
4571 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4572 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004573 }
4574
4575 return skip;
4576}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004577
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004578bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004579 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07004580 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07004581
4582 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004583 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
4584 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07004585 }
4586 return skip;
4587}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004588
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004589bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
4590 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004591 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004592 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004593
4594 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004595 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004596 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004597 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
4598 "vkCmdDispatch(): baseGroupX (%" PRIu32
4599 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4600 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004601 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004602 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
4603 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
4604 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
4605 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004606 }
4607
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004608 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004609 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004610 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
4611 "vkCmdDispatch(): baseGroupY (%" PRIu32
4612 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4613 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004614 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004615 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
4616 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
4617 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
4618 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004619 }
4620
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004621 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004622 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004623 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
4624 "vkCmdDispatch(): baseGroupZ (%" PRIu32
4625 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4626 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004627 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004628 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
4629 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
4630 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
4631 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07004632 }
4633
4634 return skip;
4635}
4636
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004637bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
4638 VkPipelineBindPoint pipelineBindPoint,
4639 VkPipelineLayout layout, uint32_t set,
4640 uint32_t descriptorWriteCount,
4641 const VkWriteDescriptorSet *pDescriptorWrites) const {
4642 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
4643}
4644
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004645bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
4646 uint32_t firstExclusiveScissor,
4647 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004648 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004649 bool skip = false;
4650
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004651 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05004652 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004653 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004654 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
4655 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
4656 ") is not 0.",
4657 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004658 }
4659 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004660 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004661 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
4662 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
4663 ") is not 1.",
4664 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004665 }
4666 } else { // multiViewport enabled
4667 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004668 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004669 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
4670 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
4671 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4672 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004673 }
4674 }
4675
Jeff Bolz3e71f782018-08-29 23:15:45 -05004676 if (pExclusiveScissors) {
4677 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
4678 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
4679
4680 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004681 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4682 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4683 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004684 }
4685
4686 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004687 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4688 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4689 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004690 }
4691
4692 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4693 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004694 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4695 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4696 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4697 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004698 }
4699
4700 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4701 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004702 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4703 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4704 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4705 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004706 }
4707 }
4708 }
4709
4710 return skip;
4711}
4712
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004713bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4714 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004715 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004716 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07004717 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4718 if ((sum < 1) || (sum > device_limits.maxViewports)) {
4719 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4720 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4721 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4722 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004723 }
4724
4725 return skip;
4726}
4727
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004728bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4729 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004730 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004731 bool skip = false;
4732
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004733 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004734 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004735 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004736 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4737 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4738 ") is not 0.",
4739 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004740 }
4741 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004742 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004743 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4744 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4745 ") is not 1.",
4746 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004747 }
4748 }
4749
Jeff Bolz9af91c52018-09-01 21:53:57 -05004750 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004751 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004752 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4753 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4754 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4755 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004756 }
4757
4758 return skip;
4759}
4760
Jeff Bolz5c801d12019-10-09 10:38:45 -05004761bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4762 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4763 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004764 bool skip = false;
4765
Dave Houlton142c4cb2018-10-17 15:04:41 -06004766 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004767 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4768 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4769 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004770 }
4771
4772 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004773 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004774 }
4775
4776 return skip;
4777}
4778
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004779bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004780 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004781 bool skip = false;
4782
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004783 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004784 skip |= LogError(
4785 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004786 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4787 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004788 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004789 }
4790
4791 return skip;
4792}
4793
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004794bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4795 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004796 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004797 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004798 static const int condition_multiples = 0b0011;
4799 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004800 skip |= LogError(
4801 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004802 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004803 }
Lockee1c22882019-06-10 16:02:54 -06004804 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004805 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4806 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4807 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4808 stride);
Lockee1c22882019-06-10 16:02:54 -06004809 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004810 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004811 skip |= LogError(
4812 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4813 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004814 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004815 if (drawCount > device_limits.maxDrawIndirectCount) {
4816 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004817 "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).",
4818 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004819 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004820 return skip;
4821}
4822
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004823bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4824 VkDeviceSize offset, VkBuffer countBuffer,
4825 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004826 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004827 bool skip = false;
4828
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004829 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004830 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4831 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4832 "), is not a multiple of 4.",
4833 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004834 }
4835
4836 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004837 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4838 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4839 "), is not a multiple of 4.",
4840 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004841 }
4842
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004843 return skip;
4844}
4845
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004846bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004847 const VkAllocationCallbacks *pAllocator,
4848 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004849 bool skip = false;
4850
4851 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4852 if (pCreateInfo != nullptr) {
4853 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4854 // VkQueryPipelineStatisticFlagBits values
4855 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4856 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004857 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4858 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4859 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4860 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004861 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004862 if (pCreateInfo->queryCount == 0) {
4863 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4864 "vkCreateQueryPool(): queryCount must be greater than zero.");
4865 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004866 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004867 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004868}
4869
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004870bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4871 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004872 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004873 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4874 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004875}
4876
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004877void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004878 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4879 VkResult result) {
4880 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004881 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004882}
4883
Mike Schuchardt2df08912020-12-15 16:28:09 -08004884void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004885 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4886 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004887 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004888 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004889 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004890}
4891
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004892void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4893 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004894 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004895 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004896 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004897}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004898
Tony-LunarG3c287f62020-12-17 12:39:49 -07004899void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004900 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004901 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
4902 auto lock = cb_write_lock();
4903 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06004904 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004905 }
4906 }
4907}
4908
4909void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004910 const VkCommandBuffer *pCommandBuffers) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004911 auto lock = cb_write_lock();
4912 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
4913 secondary_cb_map.erase(pCommandBuffers[cb_index]);
4914 }
4915}
4916
4917void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004918 const VkAllocationCallbacks *pAllocator) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004919 auto lock = cb_write_lock();
4920 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
4921 if (item->second == commandPool) {
4922 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004923 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07004924 ++item;
4925 }
4926 }
4927}
4928
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004929bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004930 const VkAllocationCallbacks *pAllocator,
4931 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004932 bool skip = false;
4933
4934 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004935 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004936 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004937 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4938 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004939 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004940
4941 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004942 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004943 if (flags_info) {
4944 flags = flags_info->flags;
4945 }
4946
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004947 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004948 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08004949 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004950 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4951 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08004952 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004953 }
4954
4955#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004956 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004957#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004958 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4959 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004960#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004961 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004962#endif
4963
4964 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004965 skip |= LogError(
4966 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004967 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4968 }
4969 if (
4970#ifdef VK_USE_PLATFORM_WIN32_KHR
4971 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4972#endif
4973 (import_memory_fd && import_memory_fd->handleType) ||
4974#ifdef VK_USE_PLATFORM_ANDROID_KHR
4975 (import_memory_ahb && import_memory_ahb->buffer) ||
4976#endif
4977 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004978 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4979 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004980 }
4981 }
4982
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02004983 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
4984 if (export_memory) {
4985 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
4986 if (export_memory_nv) {
4987 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
4988 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
4989 "VkExportMemoryAllocateInfoNV");
4990 }
4991#ifdef VK_USE_PLATFORM_WIN32_KHR
4992 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
4993 if (export_memory_win32_nv) {
4994 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
4995 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
4996 "VkExportMemoryWin32HandleInfoNV");
4997 }
4998#endif
4999 }
5000
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005001 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005002 VkBool32 capture_replay = false;
5003 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005004 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005005 if (vulkan_12_features) {
5006 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5007 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5008 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005009 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005010 if (bda_features) {
5011 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5012 buffer_device_address = bda_features->bufferDeviceAddress;
5013 }
5014 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005015 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005016 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005017 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005018 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005019 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005020 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005021 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005022 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005023 }
5024 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005025 }
5026 return skip;
5027}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005028
Jason Macnak192fa0e2019-07-26 15:07:16 -07005029bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005030 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005031 bool skip = false;
5032
5033 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5034 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5035 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005036 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005037 } else {
5038 uint32_t vertex_component_size = 0;
5039 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5040 vertex_component_size = 4;
5041 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5042 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5043 vertex_component_size = 2;
5044 }
5045 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005046 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005047 }
5048 }
5049
5050 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5051 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005052 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005053 } else {
5054 uint32_t index_element_size = 0;
5055 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5056 index_element_size = 4;
5057 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5058 index_element_size = 2;
5059 }
5060 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005061 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005062 }
5063 }
5064 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5065 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005066 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005067 }
5068 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005069 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005070 }
5071 }
5072
5073 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005074 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005075 }
5076
5077 return skip;
5078}
5079
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005080bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5081 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005082 bool skip = false;
5083
5084 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005085 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005086 }
5087 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005088 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005089 }
5090
5091 return skip;
5092}
5093
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005094bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5095 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005096 bool skip = false;
5097 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005098 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005099 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005100 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005101 }
5102 return skip;
5103}
5104
5105bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005106 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005107 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005108 bool skip = false;
5109 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005110 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5111 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5112 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005113 }
5114 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005115 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5116 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5117 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005118 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005119 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5120 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5121 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5122 }
Jason Macnak5c954952019-07-09 15:46:12 -07005123 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5124 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005125 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5126 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5127 "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 -07005128 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005129 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005130 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005131 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5132 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005133 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5134 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005135 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005136 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005137 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5138 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5139 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005140 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005141 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005142 uint64_t total_triangle_count = 0;
5143 for (uint32_t i = 0; i < info.geometryCount; i++) {
5144 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005145
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005146 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005147
Jason Macnak5c954952019-07-09 15:46:12 -07005148 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5149 continue;
5150 }
5151 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5152 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005153 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005154 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5155 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5156 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005157 }
5158 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005159 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5160 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5161 for (uint32_t i = 1; i < info.geometryCount; i++) {
5162 const VkGeometryNV &geometry = info.pGeometries[i];
5163 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005164 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005165 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
5166 "info.pGeometries[0].geometryType.",
5167 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005168 }
5169 }
5170 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005171 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5172 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5173 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5174 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5175 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5176 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5177 }
5178 }
5179 skip |=
5180 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005181 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005182 return skip;
5183}
5184
Ricardo Garciaa4935972019-02-21 17:43:18 +01005185bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5186 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005187 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005188 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005189 if (pCreateInfo) {
5190 if ((pCreateInfo->compactedSize != 0) &&
5191 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005192 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5193 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5194 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5195 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005196 }
Jason Macnak5c954952019-07-09 15:46:12 -07005197
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005198 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005199 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005200 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005201 return skip;
5202}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005203
Jeff Bolz5c801d12019-10-09 10:38:45 -05005204bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5205 const VkAccelerationStructureInfoNV *pInfo,
5206 VkBuffer instanceData, VkDeviceSize instanceOffset,
5207 VkBool32 update, VkAccelerationStructureNV dst,
5208 VkAccelerationStructureNV src, VkBuffer scratch,
5209 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005210 bool skip = false;
5211
5212 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005213 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005214 }
5215
5216 return skip;
5217}
5218
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005219bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5220 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5221 VkAccelerationStructureKHR *pAccelerationStructure) const {
5222 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005223 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005224 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005225 if (!acceleration_structure_features ||
5226 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5227 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5228 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5229 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005230 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005231 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5232 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005233 (acceleration_structure_features &&
5234 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005235 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005236 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5237 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5238 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5239 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005240 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005241 if (pCreateInfo->deviceAddress &&
5242 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5243 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5244 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5245 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5246 }
5247 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5248 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005249 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes", pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005250 }
sourav parmar83c31b12020-05-06 12:30:54 -07005251 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005252 return skip;
5253}
5254
Jason Macnak5c954952019-07-09 15:46:12 -07005255bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5256 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005257 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005258 bool skip = false;
5259 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005260 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5261 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005262 }
5263 return skip;
5264}
5265
sourav parmarcd5fb182020-07-17 12:58:44 -07005266bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5267 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5268 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5269 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005270 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07005271 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07005272 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005273 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005274 }
5275 return skip;
5276}
5277
Peter Chen85366392019-05-14 15:20:11 -04005278bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5279 uint32_t createInfoCount,
5280 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5281 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005282 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005283 bool skip = false;
5284
5285 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005286 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5287 std::stringstream msg;
5288 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5289 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
5290 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005291 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005292 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005293 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005294 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5295 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5296 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5297 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005298 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005299
5300 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005301 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005302 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5303 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5304 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5305 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5306 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5307 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5308 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5309 }
5310 }
5311
sourav parmarf4a78252020-04-10 13:04:21 -07005312 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5313 skip |=
5314 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5315 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5316 }
5317 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5318 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5319 skip |=
5320 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5321 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5322 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5323 }
5324 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5325 if (pCreateInfos[i].basePipelineIndex != -1) {
5326 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5327 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5328 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5329 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5330 "and pCreateInfos->basePipelineIndex is not -1.");
5331 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005332 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005333 skip |=
5334 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5335 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5336 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5337 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5338 "that element.");
5339 }
sourav parmarf4a78252020-04-10 13:04:21 -07005340 }
5341 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005342 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005343 skip |=
5344 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5345 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5346 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5347 "commands pCreateInfos parameter.");
5348 }
5349 } else {
5350 if (pCreateInfos[i].basePipelineIndex != -1) {
5351 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5352 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5353 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5354 }
5355 }
5356 }
5357 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5358 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5359 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5360 }
5361 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5362 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5363 "vkCreateRayTracingPipelinesNV: flags must not include "
5364 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5365 }
5366 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5367 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5368 "vkCreateRayTracingPipelinesNV: flags must not include "
5369 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5370 }
5371 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5372 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5373 "vkCreateRayTracingPipelinesNV: flags must not include "
5374 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5375 }
5376 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5377 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5378 "vkCreateRayTracingPipelinesNV: flags must not include "
5379 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5380 }
5381 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5382 skip |= LogError(
5383 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5384 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5385 }
5386 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5387 skip |= LogError(
5388 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5389 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5390 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005391 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5392 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5393 "vkCreateRayTracingPipelinesNV: flags must not include "
5394 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5395 }
5396 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5397 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5398 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5399 }
Peter Chen85366392019-05-14 15:20:11 -04005400 }
5401
5402 return skip;
5403}
5404
sourav parmarcd5fb182020-07-17 12:58:44 -07005405bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5406 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5407 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005408 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005409 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005410 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5411 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5412 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005413 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005414 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005415 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5416 std::stringstream msg;
5417 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5418 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
5419 &pCreateInfos[i].pStages[i]);
5420 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005421 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5422 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5423 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5424 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5425 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5426 }
5427 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5428 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5429 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5430 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
5431 }
5432 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005433 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005434 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
5435 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07005436 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
5437 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
5438 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005439 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
5440 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
5441 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005442 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005443 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005444 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5445 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5446 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5447 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07005448 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07005449 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5450 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5451 }
5452 }
sourav parmarf4a78252020-04-10 13:04:21 -07005453 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005454 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
5455 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07005456 }
5457 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005458 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07005459 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07005460 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
5461 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005462 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005463 }
5464 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5465 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
5466 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07005467 }
5468 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
5469 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
5470 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
5471 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
5472 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
5473 skip |= LogError(
5474 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07005475 "vkCreateRayTracingPipelinesKHR: If flags includes "
5476 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005477 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5478 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
5479 "must not be VK_SHADER_UNUSED_KHR");
5480 }
5481 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
5482 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
5483 skip |= LogError(
5484 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07005485 "vkCreateRayTracingPipelinesKHR: If flags includes "
5486 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005487 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5488 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
5489 "element must not be VK_SHADER_UNUSED_KHR");
5490 }
5491 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005492 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
5493 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
5494 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
5495 skip |= LogError(
5496 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
5497 "vkCreateRayTracingPipelinesKHR: If "
5498 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
5499 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
5500 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5501 }
5502 }
sourav parmarf4a78252020-04-10 13:04:21 -07005503 }
5504 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5505 if (pCreateInfos[i].basePipelineIndex != -1) {
5506 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5507 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07005508 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07005509 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5510 "and pCreateInfos->basePipelineIndex is not -1.");
5511 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005512 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005513 skip |=
5514 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
5515 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
5516 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
5517 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
5518 "element.");
5519 }
sourav parmarf4a78252020-04-10 13:04:21 -07005520 }
5521 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005522 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005523 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005524 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005525 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
5526 "commands pCreateInfos parameter %d.",
5527 pCreateInfos[i].basePipelineIndex, createInfoCount);
5528 }
5529 } else {
5530 if (pCreateInfos[i].basePipelineIndex != -1) {
5531 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07005532 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07005533 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5534 }
5535 }
5536 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005537 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
5538 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
5539 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
5540 "vkCreateRayTracingPipelinesKHR: If flags includes "
5541 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
5542 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005543 }
5544 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
5545 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
5546 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
5547 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
5548 "pLibraryInfo and pLibraryInterface must be NULL.");
5549 }
5550 if (pCreateInfos[i].pLibraryInfo) {
5551 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
5552 if (pCreateInfos[i].stageCount == 0) {
5553 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
5554 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5555 "stageCount must not be 0.");
5556 }
5557 if (pCreateInfos[i].groupCount == 0) {
5558 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
5559 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
5560 "groupCount must not be 0.");
5561 }
5562 } else {
5563 if (pCreateInfos[i].pLibraryInterface == NULL) {
5564 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
5565 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
5566 "is greater than 0, its "
5567 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005568 }
5569 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005570 }
5571 if (pCreateInfos[i].pLibraryInterface) {
5572 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
5573 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
5574 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
5575 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
5576 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
5577 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005578 }
5579 if (deferredOperation != VK_NULL_HANDLE) {
5580 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
5581 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
5582 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
5583 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07005584 }
5585 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005586 }
5587
5588 return skip;
5589}
5590
Mike Schuchardt21638df2019-03-16 10:52:02 -07005591#ifdef VK_USE_PLATFORM_WIN32_KHR
5592bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
5593 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005594 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07005595 bool skip = false;
5596 if (!device_extensions.vk_khr_swapchain)
5597 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
Mike Schuchardtc57de4a2021-07-20 17:26:32 -07005598 if (!device_extensions.vk_khr_get_surface_capabilities2)
Mike Schuchardt21638df2019-03-16 10:52:02 -07005599 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
5600 if (!device_extensions.vk_khr_surface)
5601 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
Mike Schuchardtc57de4a2021-07-20 17:26:32 -07005602 if (!device_extensions.vk_khr_get_physical_device_properties2)
Mike Schuchardt21638df2019-03-16 10:52:02 -07005603 skip |=
5604 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
5605 if (!device_extensions.vk_ext_full_screen_exclusive)
5606 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
5607 skip |= validate_struct_type(
5608 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
5609 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
5610 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
5611 if (pSurfaceInfo != NULL) {
5612 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
5613 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
5614 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
5615
5616 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
5617 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
5618 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
5619 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08005620 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
5621 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07005622
5623 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
5624 }
5625 return skip;
5626}
5627#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01005628
5629bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
5630 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005631 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005632 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5633 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08005634 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01005635 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
5636 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
5637 }
5638 return skip;
5639}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005640
5641bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005642 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005643 bool skip = false;
5644
5645 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005646 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
5647 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05005648 }
5649
5650 return skip;
5651}
Piers Daniell8fd03f52019-08-21 12:07:53 -06005652
5653bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005654 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06005655 bool skip = false;
5656
5657 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005658 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
5659 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005660 }
5661
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005662 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06005663 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005664 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
5665 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06005666 }
5667
5668 return skip;
5669}
Mark Lobodzinski84988402019-09-11 15:27:30 -06005670
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005671bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5672 uint32_t bindingCount, const VkBuffer *pBuffers,
5673 const VkDeviceSize *pOffsets) const {
5674 bool skip = false;
5675 if (firstBinding > device_limits.maxVertexInputBindings) {
5676 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
5677 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
5678 device_limits.maxVertexInputBindings);
5679 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5680 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
5681 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5682 "maxVertexInputBindings (%u)",
5683 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5684 }
5685
Jeff Bolz165818a2020-05-08 11:19:03 -05005686 for (uint32_t i = 0; i < bindingCount; ++i) {
5687 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005688 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05005689 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5690 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5691 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5692 } else {
5693 if (pOffsets[i] != 0) {
5694 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5695 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5696 }
5697 }
5698 }
5699 }
5700
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005701 return skip;
5702}
5703
Mark Lobodzinski84988402019-09-11 15:27:30 -06005704bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005705 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005706 bool skip = false;
5707 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005708 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5709 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005710 }
5711 return skip;
5712}
5713
5714bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005715 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005716 bool skip = false;
5717 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005718 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5719 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005720 }
5721 return skip;
5722}
Petr Kraus3d720392019-11-13 02:52:39 +01005723
5724bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5725 VkSemaphore semaphore, VkFence fence,
5726 uint32_t *pImageIndex) const {
5727 bool skip = false;
5728
5729 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005730 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5731 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005732 }
5733
5734 return skip;
5735}
5736
5737bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5738 uint32_t *pImageIndex) const {
5739 bool skip = false;
5740
5741 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005742 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5743 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005744 }
5745
5746 return skip;
5747}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005748
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005749bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5750 uint32_t firstBinding, uint32_t bindingCount,
5751 const VkBuffer *pBuffers,
5752 const VkDeviceSize *pOffsets,
5753 const VkDeviceSize *pSizes) const {
5754 bool skip = false;
5755
5756 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5757 for (uint32_t i = 0; i < bindingCount; ++i) {
5758 if (pOffsets[i] & 3) {
5759 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5760 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5761 }
5762 }
5763
5764 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5765 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5766 "%s: The firstBinding(%" PRIu32
5767 ") index is greater than or equal to "
5768 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5769 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5770 }
5771
5772 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5773 skip |=
5774 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5775 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5776 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5777 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5778 }
5779
5780 for (uint32_t i = 0; i < bindingCount; ++i) {
5781 // pSizes is optional and may be nullptr.
5782 if (pSizes != nullptr) {
5783 if (pSizes[i] != VK_WHOLE_SIZE &&
5784 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5785 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5786 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5787 ") is not VK_WHOLE_SIZE and is greater than "
5788 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5789 cmd_name, i, pSizes[i]);
5790 }
5791 }
5792 }
5793
5794 return skip;
5795}
5796
5797bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5798 uint32_t firstCounterBuffer,
5799 uint32_t counterBufferCount,
5800 const VkBuffer *pCounterBuffers,
5801 const VkDeviceSize *pCounterBufferOffsets) const {
5802 bool skip = false;
5803
5804 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5805 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5806 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5807 "%s: The firstCounterBuffer(%" PRIu32
5808 ") index is greater than or equal to "
5809 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5810 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5811 }
5812
5813 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5814 skip |=
5815 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5816 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5817 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5818 cmd_name, firstCounterBuffer, counterBufferCount,
5819 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5820 }
5821
5822 return skip;
5823}
5824
5825bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5826 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5827 const VkBuffer *pCounterBuffers,
5828 const VkDeviceSize *pCounterBufferOffsets) const {
5829 bool skip = false;
5830
5831 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5832 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5833 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5834 "%s: The firstCounterBuffer(%" PRIu32
5835 ") index is greater than or equal to "
5836 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5837 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5838 }
5839
5840 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5841 skip |=
5842 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5843 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5844 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5845 cmd_name, firstCounterBuffer, counterBufferCount,
5846 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5847 }
5848
5849 return skip;
5850}
5851
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005852bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5853 uint32_t firstInstance, VkBuffer counterBuffer,
5854 VkDeviceSize counterBufferOffset,
5855 uint32_t counterOffset, uint32_t vertexStride) const {
5856 bool skip = false;
5857
5858 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005859 skip |= LogError(
5860 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005861 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5862 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5863 }
5864
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005865 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08005866 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06005867 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005868 }
5869
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005870 return skip;
5871}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005872
5873bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5874 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5875 const VkAllocationCallbacks *pAllocator,
5876 VkSamplerYcbcrConversion *pYcbcrConversion,
5877 const char *apiName) const {
5878 bool skip = false;
5879
5880 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005881 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005882 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005883 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005884 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5885 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005886 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005887 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005888 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005889
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005890#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005891 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005892 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005893#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005894 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005895#endif
5896
sfricke-samsung1a72f942020-07-25 12:09:18 -07005897 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005898
5899 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005900 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005901 const VkComponentMapping components = pCreateInfo->components;
5902 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5903 if (FormatIsXChromaSubsampled(format) == true) {
5904 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5905 skip |=
5906 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005907 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5908 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005909 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005910 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005911
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005912 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5913 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5914 skip |= LogError(
5915 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5916 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5917 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5918 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5919 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005920
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005921 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5922 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5923 skip |=
5924 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005925 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5926 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005927 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005928 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005929
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005930 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5931 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5932 skip |=
5933 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005934 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5935 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005936 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005937 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005938
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005939 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005940 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5941 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5942 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005943 skip |=
5944 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005945 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5946 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005947 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5948 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005949 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005950 }
5951
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005952 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5953 // Checks same VU multiple ways in order to give a more useful error message
5954 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5955 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5956 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5957 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5958 skip |= LogError(
5959 device, vuid,
5960 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5961 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5962 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5963 string_VkComponentSwizzle(components.b));
5964 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005965
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005966 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5967 // 4 channel format = no issue
5968 // 3 = no [a]
5969 // 2 = no [b,a]
5970 // 1 = no [g,b,a]
5971 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5972 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5973
5974 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5975 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5976 skip |= LogError(device, vuid,
5977 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5978 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5979 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5980 string_VkComponentSwizzle(components.b));
5981 } else if ((channels < 3) &&
5982 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5983 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5984 skip |= LogError(device, vuid,
5985 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5986 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5987 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5988 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5989 string_VkComponentSwizzle(components.b));
5990 } else if ((channels < 2) &&
5991 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5992 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5993 skip |= LogError(device, vuid,
5994 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5995 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5996 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5997 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5998 string_VkComponentSwizzle(components.b));
5999 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006000 }
6001 }
6002
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006003 return skip;
6004}
6005
6006bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6007 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6008 const VkAllocationCallbacks *pAllocator,
6009 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6010 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6011 "vkCreateSamplerYcbcrConversion");
6012}
6013
6014bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6015 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6016 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6017 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6018 "vkCreateSamplerYcbcrConversionKHR");
6019}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006020
6021bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6022 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6023 bool skip = false;
6024 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6025 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6026
6027 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006028 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6029 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6030 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6031 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6032 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006033 }
6034 return skip;
6035}
sourav parmara96ab1a2020-04-25 16:28:23 -07006036
6037bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006038 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006039 bool skip = false;
6040 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6041 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6042 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6043 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006044 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006045 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6046 skip |= LogError(
6047 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6048 "vkCopyAccelerationStructureToMemoryKHR: The "
6049 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6050 }
6051 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6052 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6053 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6054 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6055 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6056 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006057 return skip;
6058}
6059
6060bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6061 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6062 bool skip = false;
6063 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6064 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6065 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6066 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6067 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006068 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6069 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006070 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006071 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006072 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006073 return skip;
6074}
6075
6076bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6077 const char *api_name) const {
6078 bool skip = false;
6079 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6080 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6081 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6082 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6083 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6084 api_name);
6085 }
6086 return skip;
6087}
6088
6089bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006090 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006091 bool skip = false;
6092 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006093 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006094 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006095 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006096 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6097 "vkCopyAccelerationStructureKHR: The "
6098 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006099 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006100 return skip;
6101}
6102
6103bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6104 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6105 bool skip = false;
6106 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6107 return skip;
6108}
6109
6110bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006111 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006112 bool skip = false;
6113 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006114 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006115 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6116 }
6117 return skip;
6118}
6119
6120bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006121 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006122 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006123 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006124 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006125 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6126 skip |= LogError(
6127 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6128 "vkCopyMemoryToAccelerationStructureKHR: The "
6129 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006130 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006131 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6132 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006133 return skip;
6134}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006135
sourav parmara96ab1a2020-04-25 16:28:23 -07006136bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6137 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6138 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006139 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006140 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6141 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006142 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006143 pInfo->src.deviceAddress);
6144 }
sourav parmar83c31b12020-05-06 12:30:54 -07006145 return skip;
6146}
6147bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6148 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6149 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6150 bool skip = false;
6151 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6152 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6153 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6154 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6155 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6156 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6157 }
6158 return skip;
6159}
6160bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6161 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6162 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6163 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006164 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006165 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6166 skip |= LogError(
6167 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6168 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6169 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6170 }
sourav parmar83c31b12020-05-06 12:30:54 -07006171 if (dataSize < accelerationStructureCount * stride) {
6172 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6173 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
6174 "accelerationStructureCount (%d) *stride(%zu).",
6175 dataSize, accelerationStructureCount, stride);
6176 }
6177 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6178 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6179 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6180 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6181 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6182 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6183 }
6184 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6185 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6186 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6187 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6188 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6189 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6190 stride);
6191 }
6192 }
6193 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6194 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6195 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6196 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6197 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6198 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6199 stride);
6200 }
6201 }
sourav parmar83c31b12020-05-06 12:30:54 -07006202 return skip;
6203}
6204bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6205 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6206 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006207 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006208 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6209 skip |= LogError(
6210 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6211 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6212 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006213 }
6214 return skip;
6215}
6216
6217bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006218 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6219 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6220 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6221 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006222 uint32_t width, uint32_t height, uint32_t depth) const {
6223 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006224 // RayGen
6225 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6226 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6227 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006228 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006229 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6230 0) {
6231 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6232 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6233 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6234 }
6235 // Callable
6236 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6237 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6238 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6239 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006240 }
6241 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6242 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6243 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006244 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6245 }
6246 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6247 0) {
6248 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6249 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6250 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006251 }
6252 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006253 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6254 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6255 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6256 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006257 }
6258 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6259 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006260 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6261 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006262 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006263 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6264 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
6265 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6266 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6267 }
sourav parmar83c31b12020-05-06 12:30:54 -07006268 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006269 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6270 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
6271 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
6272 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07006273 }
6274 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6275 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
6276 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006277 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6278 }
6279 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6280 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
6281 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6282 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6283 }
6284 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
6285 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
6286 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
6287 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
6288 }
6289 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6290 skip |=
6291 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6292 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6293 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006294 }
6295
sourav parmarcd5fb182020-07-17 12:58:44 -07006296 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6297 skip |=
6298 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6299 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6300 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6301 }
6302
6303 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6304 skip |=
6305 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6306 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6307 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006308 }
6309 return skip;
6310}
6311
sourav parmarcd5fb182020-07-17 12:58:44 -07006312bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6313 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6314 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6315 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006316 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006317 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006318 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6319 skip |= LogError(
6320 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6321 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6322 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006323 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006324 // RayGen
6325 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6326 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6327 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006328 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006329 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6330 0) {
6331 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6332 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6333 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6334 }
6335 // Callabe
6336 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6337 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6338 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6339 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006340 }
6341 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6342 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006343 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6344 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6345 }
6346 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6347 0) {
6348 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6349 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6350 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006351 }
6352 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006353 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6354 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6355 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6356 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006357 }
6358 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6359 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006360 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6361 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006362 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006363 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6364 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6365 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6366 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6367 }
sourav parmar83c31b12020-05-06 12:30:54 -07006368 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006369 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6370 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6371 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6372 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006373 }
6374 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6375 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006376 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6377 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6378 }
6379 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6380 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6381 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6382 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006383 }
6384
sourav parmarcd5fb182020-07-17 12:58:44 -07006385 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
6386 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
6387 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07006388 }
6389 return skip;
6390}
6391bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
6392 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
6393 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
6394 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
6395 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
6396 uint32_t width, uint32_t height, uint32_t depth) const {
6397 bool skip = false;
6398 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6399 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
6400 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
6401 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6402 }
6403 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6404 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
6405 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
6406 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6407 }
6408 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6409 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
6410 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
6411 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
6412 }
6413
6414 // hitShader
6415 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6416 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
6417 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
6418 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6419 }
6420 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6421 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
6422 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
6423 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6424 }
6425 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6426 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
6427 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
6428 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6429 }
6430
6431 // missShader
6432 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6433 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
6434 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
6435 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6436 }
6437 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6438 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
6439 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
6440 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6441 }
6442 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6443 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
6444 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
6445 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6446 }
6447
6448 // raygenShader
6449 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6450 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
6451 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07006452 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6453 }
6454 if (width > device_limits.maxComputeWorkGroupCount[0]) {
6455 skip |=
6456 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
6457 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
6458 }
6459 if (height > device_limits.maxComputeWorkGroupCount[1]) {
6460 skip |=
6461 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
6462 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
6463 }
6464 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
6465 skip |=
6466 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
6467 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07006468 }
6469 return skip;
6470}
6471
sourav parmar83c31b12020-05-06 12:30:54 -07006472bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006473 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
6474 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006475 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006476 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6477 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006478 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
6479 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006480 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07006481 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
6482 }
6483 return skip;
6484}
6485
Piers Daniell39842ee2020-07-10 16:42:33 -06006486bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
6487 const VkViewport *pViewports) const {
6488 bool skip = false;
6489
6490 if (!physical_device_features.multiViewport) {
6491 if (viewportCount != 1) {
6492 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
6493 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
6494 ") is not 1.",
6495 viewportCount);
6496 }
6497 } else { // multiViewport enabled
6498 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
6499 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
6500 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
6501 ") must "
6502 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6503 viewportCount, device_limits.maxViewports);
6504 }
6505 }
6506
6507 if (pViewports) {
6508 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
6509 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
6510 const char *fn_name = "vkCmdSetViewportWithCountEXT";
6511 skip |= manual_PreCallValidateViewport(
6512 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
6513 }
6514 }
6515
6516 return skip;
6517}
6518
6519bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
6520 const VkRect2D *pScissors) const {
6521 bool skip = false;
6522
6523 if (!physical_device_features.multiViewport) {
6524 if (scissorCount != 1) {
6525 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
6526 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6527 ") must "
6528 "be 1 when the multiViewport feature is disabled.",
6529 scissorCount);
6530 }
6531 } else { // multiViewport enabled
6532 if (scissorCount == 0) {
6533 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6534 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6535 ") must "
6536 "be great than zero.",
6537 scissorCount);
6538 } else if (scissorCount > device_limits.maxViewports) {
6539 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
6540 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
6541 ") must "
6542 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6543 scissorCount, device_limits.maxViewports);
6544 }
6545 }
6546
6547 if (pScissors) {
6548 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
6549 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
6550
6551 if (scissor.offset.x < 0) {
6552 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6553 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
6554 scissor.offset.x);
6555 }
6556
6557 if (scissor.offset.y < 0) {
6558 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
6559 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
6560 scissor.offset.y);
6561 }
6562
6563 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
6564 if (x_sum > INT32_MAX) {
6565 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
6566 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6567 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6568 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
6569 }
6570
6571 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
6572 if (y_sum > INT32_MAX) {
6573 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
6574 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
6575 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
6576 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
6577 }
6578 }
6579 }
6580
6581 return skip;
6582}
6583
6584bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6585 uint32_t bindingCount, const VkBuffer *pBuffers,
6586 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
6587 const VkDeviceSize *pStrides) const {
6588 bool skip = false;
6589 if (firstBinding >= device_limits.maxVertexInputBindings) {
6590 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
6591 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
6592 firstBinding, device_limits.maxVertexInputBindings);
6593 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6594 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
6595 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
6596 "maxVertexInputBindings (%u)",
6597 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6598 }
6599
6600 for (uint32_t i = 0; i < bindingCount; ++i) {
6601 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006602 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06006603 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
6604 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
6605 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
6606 } else {
6607 if (pOffsets[i] != 0) {
6608 skip |=
6609 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
6610 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
6611 }
6612 }
6613 }
6614 if (pStrides) {
6615 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
6616 skip |=
6617 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006618 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%u)", i,
Piers Daniell39842ee2020-07-10 16:42:33 -06006619 pStrides[i], device_limits.maxVertexInputBindingStride);
6620 }
6621 }
6622 }
6623
6624 return skip;
6625}
sourav parmarcd5fb182020-07-17 12:58:44 -07006626
6627bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
6628 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
6629 bool skip = false;
6630 for (uint32_t i = 0; i < infoCount; ++i) {
6631 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6632 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
6633 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
6634 }
6635 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
6636 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
6637 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
6638 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
6639 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
6640 api_name);
6641 }
6642 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
6643 skip |=
6644 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
6645 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
6646 }
6647 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
6648 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
6649 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
6650 }
6651 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
6652 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
6653 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
6654 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
6655 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
6656 api_name);
6657 }
6658 if (pInfos[i].pGeometries) {
6659 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6660 skip |= validate_ranged_enum(
6661 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
6662 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
6663 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6664 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006665 skip |= validate_struct_type(
6666 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
6667 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6668 &(pInfos[i].pGeometries[j].geometry.triangles),
6669 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6670 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6671 skip |= validate_struct_pnext(
6672 api_name,
6673 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6674 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6675 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6676 skip |=
6677 validate_ranged_enum(api_name,
6678 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6679 ParameterName::IndexVector{i, j}),
6680 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6681 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6682 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6683 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6684 &pInfos[i].pGeometries[j].geometry.triangles,
6685 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6686 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6687 skip |= validate_ranged_enum(
6688 api_name,
6689 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6690 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6691 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6692
6693 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6694 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6695 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6696 }
6697 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6698 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6699 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6700 skip |=
6701 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6702 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6703 api_name);
6704 }
6705 }
6706 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6707 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6708 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6709 &pInfos[i].pGeometries[j].geometry.instances,
6710 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6711 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6712 skip |= validate_struct_type(
6713 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6714 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6715 &(pInfos[i].pGeometries[j].geometry.instances),
6716 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6717 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6718 skip |= validate_struct_pnext(
6719 api_name,
6720 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6721 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6722 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6723
6724 skip |= validate_bool32(api_name,
6725 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6726 ParameterName::IndexVector{i, j}),
6727 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6728 }
6729 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6730 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6731 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6732 &pInfos[i].pGeometries[j].geometry.aabbs,
6733 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6734 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6735 skip |= validate_struct_type(
6736 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6737 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6738 &(pInfos[i].pGeometries[j].geometry.aabbs),
6739 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6740 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6741 skip |= validate_struct_pnext(
6742 api_name,
6743 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6744 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6745 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6746 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6747 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6748 "(%s):stride must be less than or equal to 2^32-1", api_name);
6749 }
6750 }
6751 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6752 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6753 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6754 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6755 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6756 api_name);
6757 }
6758 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6759 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6760 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6761 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6762 "of elements of"
6763 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6764 api_name);
6765 }
6766 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6767 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6768 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6769 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6770 api_name);
6771 }
6772 }
6773 }
6774 }
6775 if (pInfos[i].ppGeometries != NULL) {
6776 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6777 skip |= validate_ranged_enum(
6778 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6779 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6780 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6781 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006782 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6783 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6784 &pInfos[i].ppGeometries[j]->geometry.triangles,
6785 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6786 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6787 skip |= validate_struct_type(
6788 api_name,
6789 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6790 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6791 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6792 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6793 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6794 skip |= validate_struct_pnext(
6795 api_name,
6796 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6797 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6798 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6799 skip |= validate_ranged_enum(api_name,
6800 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6801 ParameterName::IndexVector{i, j}),
6802 "VkFormat", AllVkFormatEnums,
6803 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6804 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6805 skip |= validate_ranged_enum(api_name,
6806 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6807 ParameterName::IndexVector{i, j}),
6808 "VkIndexType", AllVkIndexTypeEnums,
6809 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6810 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6811 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6812 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6813 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6814 }
6815 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6816 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6817 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6818 skip |=
6819 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6820 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6821 api_name);
6822 }
6823 }
6824 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6825 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6826 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6827 &pInfos[i].ppGeometries[j]->geometry.instances,
6828 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6829 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6830 skip |= validate_struct_type(
6831 api_name,
6832 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6833 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6834 &(pInfos[i].ppGeometries[j]->geometry.instances),
6835 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6836 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6837 skip |= validate_struct_pnext(
6838 api_name,
6839 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6840 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6841 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6842 skip |= validate_bool32(api_name,
6843 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6844 ParameterName::IndexVector{i, j}),
6845 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6846 }
6847 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6848 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6849 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6850 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6851 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6852 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6853 skip |= validate_struct_type(
6854 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6855 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6856 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6857 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6858 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6859 skip |= validate_struct_pnext(
6860 api_name,
6861 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6862 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6863 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6864 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6865 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6866 "(%s):stride must be less than or equal to 2^32-1", api_name);
6867 }
6868 }
6869 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6870 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6871 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6872 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6873 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6874 api_name);
6875 }
6876 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6877 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6878 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6879 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6880 "of elements of"
6881 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6882 api_name);
6883 }
6884 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6885 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6886 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6887 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6888 api_name);
6889 }
6890 }
6891 }
6892 }
6893 }
6894 return skip;
6895}
6896bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6897 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6898 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6899 bool skip = false;
6900 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6901 for (uint32_t i = 0; i < infoCount; ++i) {
6902 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6903 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6904 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6905 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6906 "scratchData.deviceAddress member must be a multiple of "
6907 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6908 }
6909 for (uint32_t k = 0; k < infoCount; ++k) {
6910 if (i == k) continue;
6911 bool found = false;
6912 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6913 skip |= LogError(
6914 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6915 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6916 "not be "
6917 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6918 i, k);
6919 found = true;
6920 }
6921 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6922 skip |= LogError(
6923 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
6924 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
6925 "not be "
6926 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6927 i, k);
6928 found = true;
6929 }
6930 if (found) break;
6931 }
6932 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6933 if (pInfos[i].pGeometries) {
6934 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6935 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6936 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6937 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6938 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6939 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6940 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6941 }
6942 } else {
6943 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6944 skip |=
6945 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6946 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6947 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6948 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6949 }
6950 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006951 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006952 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6953 skip |= LogError(
6954 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6955 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6956 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6957 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006958 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6959 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006960 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6961 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6962 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6963 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6964 }
6965 }
6966 } else if (pInfos[i].ppGeometries) {
6967 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6968 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6969 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6970 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6971 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6972 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6973 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6974 }
6975 } else {
6976 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6977 skip |=
6978 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6979 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6980 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6981 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6982 }
6983 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006984 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006985 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6986 skip |= LogError(
6987 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6988 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6989 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6990 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006991 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6992 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006993 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6994 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6995 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6996 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6997 }
6998 }
6999 }
7000 }
7001 }
7002 return skip;
7003}
7004
7005bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7006 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7007 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7008 const uint32_t *const *ppMaxPrimitiveCounts) const {
7009 bool skip = false;
7010 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7011 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007012 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007013 if (!ray_tracing_acceleration_structure_features ||
7014 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7015 skip |= LogError(
7016 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
7017 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
7018 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
7019 }
7020 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007021 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7022 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7023 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
7024 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
7025 "scratchData.deviceAddress member must be a multiple of "
7026 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7027 }
7028 for (uint32_t k = 0; k < infoCount; ++k) {
7029 if (i == k) continue;
7030 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
7031 skip |=
7032 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
7033 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
7034 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
7035 "any other element [%d) of pInfos.",
7036 i, k);
7037 break;
7038 }
7039 }
7040 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7041 if (pInfos[i].pGeometries) {
7042 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7043 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7044 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7045 skip |= LogError(
7046 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7047 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7048 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7049 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7050 }
7051 } else {
7052 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7053 skip |= LogError(
7054 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7055 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7056 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7057 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7058 }
7059 }
7060 }
7061 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7062 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7063 skip |= LogError(
7064 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7065 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7066 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7067 }
7068 }
7069 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7070 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7071 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7072 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7073 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7074 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7075 }
7076 }
7077 } else if (pInfos[i].ppGeometries) {
7078 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7079 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7080 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7081 skip |= LogError(
7082 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7083 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7084 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7085 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7086 }
7087 } else {
7088 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7089 skip |= LogError(
7090 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7091 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7092 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7093 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7094 }
7095 }
7096 }
7097 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7098 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7099 skip |= LogError(
7100 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7101 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7102 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7103 }
7104 }
7105 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7106 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7107 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7108 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7109 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7110 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7111 }
7112 }
7113 }
7114 }
7115 }
7116 return skip;
7117}
7118
7119bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7120 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7121 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7122 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7123 bool skip = false;
7124 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7125 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007126 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007127 if (!ray_tracing_acceleration_structure_features ||
7128 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7129 skip |=
7130 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7131 "vkBuildAccelerationStructuresKHR: The "
7132 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7133 }
7134 for (uint32_t i = 0; i < infoCount; ++i) {
7135 for (uint32_t j = 0; j < infoCount; ++j) {
7136 if (i == j) continue;
7137 bool found = false;
7138 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7139 skip |= LogError(
7140 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7141 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
7142 "not be "
7143 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7144 i, j);
7145 found = true;
7146 }
7147 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
7148 skip |= LogError(
7149 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7150 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
7151 "not be "
7152 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
7153 i, j);
7154 found = true;
7155 }
7156 if (found) break;
7157 }
7158 }
7159 return skip;
7160}
7161
7162bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7163 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7164 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7165 bool skip = false;
7166 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7167 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007168 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7169 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007170 if (!(ray_tracing_pipeline_features || ray_query_features) ||
7171 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
7172 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
7173 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
7174 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
7175 }
7176 return skip;
7177}
sfricke-samsungecafb192021-01-17 08:21:14 -08007178
7179bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
7180 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
7181 const VkAllocationCallbacks *pAllocator,
7182 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
7183 bool skip = false;
7184 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
7185 if (private_data_features && private_data_features->privateData == VK_FALSE) {
7186 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
7187 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
7188 }
7189 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07007190}
Piers Daniellcb6d8032021-04-19 18:51:26 -06007191
7192bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7193 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7194 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7195 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7196 bool skip = false;
7197 const auto *vertex_input_dynamic_state_features =
7198 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
7199 const auto *vertex_attribute_divisor_features =
7200 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7201
7202 // VUID-vkCmdSetVertexInputEXT-None-04790
7203 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
7204 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
7205 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
7206 }
7207
7208 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7209 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7210 skip |=
7211 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7212 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7213 }
7214
7215 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7216 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7217 skip |= LogError(
7218 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7219 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7220 }
7221
7222 // VUID-vkCmdSetVertexInputEXT-binding-04793
7223 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7224 bool binding_found = false;
7225 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7226 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
7227 binding_found = true;
7228 break;
7229 }
7230 }
7231 if (!binding_found) {
7232 skip |=
7233 LogError(device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
7234 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u] references an unspecified binding", attribute);
7235 }
7236 }
7237
7238 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
7239 if (vertexBindingDescriptionCount > 1) {
7240 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
7241 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
7242 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
7243 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
7244 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
7245 "vkCmdSetVertexInputEXT(): binding description for binding %u already specified", binding_value);
7246 }
7247 }
7248 }
7249 }
7250
7251 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
7252 if (vertexAttributeDescriptionCount > 1) {
7253 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
7254 uint32_t location = pVertexAttributeDescriptions[attribute].location;
7255 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
7256 if (location == pVertexAttributeDescriptions[next_attribute].location) {
7257 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
7258 "vkCmdSetVertexInputEXT(): attribute description for location %u already specified", location);
7259 }
7260 }
7261 }
7262 }
7263
7264 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7265 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
7266 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
7267 skip |= LogError(
7268 device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
7269 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].binding is greater than maxVertexInputBindings", binding);
7270 }
7271
7272 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
7273 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
7274 skip |= LogError(
7275 device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
7276 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].stride is greater than maxVertexInputBindingStride",
7277 binding);
7278 }
7279
7280 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
7281 if (pVertexBindingDescriptions[binding].divisor == 0 &&
7282 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
7283 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
7284 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is zero but "
7285 "vertexAttributeInstanceRateZeroDivisor is not enabled",
7286 binding);
7287 }
7288
7289 if (pVertexBindingDescriptions[binding].divisor > 1) {
7290 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7291 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7292 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
7293 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than one but "
7294 "vertexAttributeInstanceRateDivisor is not enabled",
7295 binding);
7296 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007297 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06007298 if (pVertexBindingDescriptions[binding].divisor >
7299 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
7300 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007301 device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007302 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than maxVertexAttribDivisor",
7303 binding);
7304 }
7305
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007306 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06007307 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
7308 skip |=
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007309 LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007310 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%u].divisor is greater than 1 but inputRate "
7311 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7312 binding);
7313 }
7314 }
7315 }
7316 }
7317
7318 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007319 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06007320 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
7321 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007322 device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007323 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].location is greater than maxVertexInputAttributes",
7324 attribute);
7325 }
7326
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007327 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06007328 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
7329 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007330 device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007331 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].binding is greater than maxVertexInputBindings",
7332 attribute);
7333 }
7334
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007335 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06007336 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
7337 skip |= LogError(
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007338 device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
Piers Daniellcb6d8032021-04-19 18:51:26 -06007339 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].offset is greater than maxVertexInputAttributeOffset",
7340 attribute);
7341 }
7342
7343 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7344 VkFormatProperties properties;
7345 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7346 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7347 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
7348 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%u].format is not a "
7349 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7350 attribute);
7351 }
7352 }
7353
7354 return skip;
7355}
sfricke-samsung51303fb2021-05-09 19:09:13 -07007356
7357bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
7358 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
7359 const void *pValues) const {
7360 bool skip = false;
7361 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
7362 // Check that offset + size don't exceed the max.
7363 // Prevent arithetic overflow here by avoiding addition and testing in this order.
7364 if (offset >= max_push_constants_size) {
7365 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00370",
7366 "vkCmdPushConstants(): offset (%u) that exceeds this device's maxPushConstantSize of %u.", offset,
7367 max_push_constants_size);
7368 }
7369 if (size > max_push_constants_size - offset) {
7370 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
7371 "vkCmdPushConstants(): offset (%u) and size (%u) that exceeds this device's maxPushConstantSize of %u.",
7372 offset, size, max_push_constants_size);
7373 }
7374
7375 // size needs to be non-zero and a multiple of 4.
7376 if (size & 0x3) {
7377 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369", "vkCmdPushConstants(): size (%u) must be a multiple of 4.",
7378 size);
7379 }
7380
7381 // offset needs to be a multiple of 4.
7382 if ((offset & 0x3) != 0) {
7383 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007384 "vkCmdPushConstants(): offset (%u) must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007385 }
7386 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007387}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02007388
7389bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
7390 uint32_t srcCacheCount,
7391 const VkPipelineCache *pSrcCaches) const {
7392 bool skip = false;
7393 if (pSrcCaches) {
7394 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
7395 if (pSrcCaches[index0] == dstCache) {
7396 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
7397 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
7398 report_data->FormatHandle(dstCache).c_str());
7399 break;
7400 }
7401 }
7402 }
7403 return skip;
7404}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06007405
7406bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
7407 VkImageLayout imageLayout, const VkClearColorValue *pColor,
7408 uint32_t rangeCount,
7409 const VkImageSubresourceRange *pRanges) const {
7410 bool skip = false;
7411 if (!pColor) {
7412 skip |=
7413 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
7414 }
7415 return skip;
7416}
7417
7418bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
7419 const VkRenderPassBeginInfo *const rp_begin) const {
7420 bool skip = false;
7421 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
7422 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
7423 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
7424 "), but VkRenderPassBeginInfo::pClearValues is not null.",
7425 func_name, rp_begin->clearValueCount);
7426 }
7427 return skip;
7428}
7429
7430bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7431 VkSubpassContents) const {
7432 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
7433 return skip;
7434}
7435
7436bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
7437 const VkRenderPassBeginInfo *pRenderPassBegin,
7438 const VkSubpassBeginInfo *) const {
7439 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
7440 return skip;
7441}
7442
7443bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7444 const VkSubpassBeginInfo *) const {
7445 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
7446 return skip;
7447}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02007448
7449bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
7450 uint32_t firstDiscardRectangle,
7451 uint32_t discardRectangleCount,
7452 const VkRect2D *pDiscardRectangles) const {
7453 bool skip = false;
7454
7455 if (pDiscardRectangles) {
7456 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
7457 const int64_t x_sum =
7458 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
7459 if (x_sum > std::numeric_limits<int32_t>::max()) {
7460 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
7461 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7462 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
7463 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
7464 }
7465
7466 const int64_t y_sum =
7467 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
7468 if (y_sum > std::numeric_limits<int32_t>::max()) {
7469 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
7470 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7471 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
7472 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
7473 }
7474 }
7475 }
7476
7477 return skip;
7478}