blob: 01c77f241f8e3873aaa3fb45211883160f48b93b [file] [log] [blame]
aitor-lunargd5301592022-01-05 22:38:16 +01001/* Copyright (c) 2015-2022 The Khronos Group Inc.
2 * Copyright (c) 2015-2022 Valve Corporation
3 * Copyright (c) 2015-2022 LunarG, Inc.
4 * Copyright (C) 2015-2022 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"
sfricke-samsung2e827212021-09-28 07:52:08 -070027#include "core_validation_error_enums.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010028
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070029static const int kMaxParamCheckerStringLength = 256;
Mark Lobodzinskid4950072017-08-01 13:02:20 -060030
John Zulauf71968502017-10-26 13:51:15 -060031template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070032inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060033 // Using only < for generality and || for early abort
34 return !((value < min) || (max < value));
35}
36
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -060037ReadLockGuard StatelessValidation::ReadLock() { return ReadLockGuard(validation_object_mutex, std::defer_lock); }
38WriteLockGuard StatelessValidation::WriteLock() { return WriteLockGuard(validation_object_mutex, std::defer_lock); }
Mark Lobodzinski21b91fe2020-12-03 15:44:24 -070039
Jeremy Gebbencbf22862021-03-03 12:01:22 -070040static layer_data::unordered_map<VkCommandBuffer, VkCommandPool> secondary_cb_map{};
Tony-LunarG3c287f62020-12-17 12:39:49 -070041static ReadWriteLock secondary_cb_map_mutex;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -060042static ReadLockGuard CBReadLock() { return ReadLockGuard(secondary_cb_map_mutex); }
43static WriteLockGuard CBWriteLock() { return WriteLockGuard(secondary_cb_map_mutex); }
Tony-LunarG3c287f62020-12-17 12:39:49 -070044
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070045bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050046 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060047 bool skip = false;
48
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070049 VkStringErrorFlags result = vk_string_validate(kMaxParamCheckerStringLength, validateString);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060050
51 if (result == VK_STRING_ERROR_NONE) {
52 return skip;
53 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070054 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -070055 kMaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060056 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070057 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
58 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060059 }
60 return skip;
61}
62
Jeff Bolz46c0ea02019-10-09 13:06:29 -050063bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060064 bool skip = false;
65 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
66 if (api_version_nopatch != effective_api_version) {
sfricke-samsung6aec21b2020-11-01 07:49:43 -080067 if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) {
68 skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070069 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
70 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
71 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060072 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070073 skip |= LogWarning(instance, kVUIDUndefined,
74 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
75 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
76 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060077 }
78 }
79 return skip;
80}
81
Jeff Bolz46c0ea02019-10-09 13:06:29 -050082bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060083 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060084 // Create and use a local instance extension object, as an actual instance has not been created yet
85 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
86 InstanceExtensions local_instance_extensions;
87 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
88
John Zulauf620755c2018-04-16 11:00:43 -060089 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060090 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
91 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060092 }
ziga-lunarg7334af32022-03-27 16:48:15 +020093 if (pCreateInfo->flags & VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR &&
94 !local_instance_extensions.vk_khr_portability_enumeration) {
95 skip |= LogError(instance, "VUID-VkInstanceCreateInfo-flags-06559",
96 "vkCreateInstance(): pCreateInfo->flags has VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR set, but "
97 "pCreateInfo->ppEnabledExtensionNames does not include VK_KHR_portability_enumeration");
98 }
John Zulauf620755c2018-04-16 11:00:43 -060099
100 return skip;
101}
102
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600103bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const {
Mike Schuchardtc57de4a2021-07-20 17:26:32 -0700104 if (instance_extensions.vk_khr_get_physical_device_properties2) {
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600105 // Struct is legal IF it's supported
106 const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device);
107 if (dev_exts_enumerated == device_extensions_enumerated.end()) return true;
108 auto enum_iter = dev_exts_enumerated->second.find(ext_name);
109 if (enum_iter != dev_exts_enumerated->second.cend()) {
110 return true;
111 }
112 }
113 return false;
114}
115
Tony-LunarG866843d2020-05-13 11:22:42 -0600116bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
117 const VkValidationFeaturesEXT *validation_features) const {
118 bool skip = false;
119 bool debug_printf = false;
120 bool gpu_assisted = false;
121 bool reserve_slot = false;
122 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
123 switch (validation_features->pEnabledValidationFeatures[i]) {
124 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
125 gpu_assisted = true;
126 break;
127
128 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
129 debug_printf = true;
130 break;
131
132 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
133 reserve_slot = true;
134 break;
135
136 default:
137 break;
138 }
139 }
140 if (reserve_slot && !gpu_assisted) {
141 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
142 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
143 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
144 }
145 if (gpu_assisted && debug_printf) {
146 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
147 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
148 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
149 }
150
151 return skip;
152}
153
John Zulauf620755c2018-04-16 11:00:43 -0600154template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700155ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
156 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600157 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700158 ExtEnabled state =
159 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600160 return state;
161}
162
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700163bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500164 const VkAllocationCallbacks *pAllocator,
165 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700166 bool skip = false;
167 // Note: From the spec--
168 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
169 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
170 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700171 ? pCreateInfo->pApplicationInfo->apiVersion
172 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700173 skip |= validate_api_version(local_api_version, api_version);
174 skip |= validate_instance_extensions(pCreateInfo);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700175 const auto *validation_features = LvlFindInChain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
Tony-LunarG866843d2020-05-13 11:22:42 -0600176 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
177
Tony-LunarG115f89d2022-06-15 10:53:22 -0600178#ifdef VK_USE_PLATFORM_METAL_EXT
179 auto export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(pCreateInfo->pNext);
180 while (export_metal_object_info) {
181 if ((export_metal_object_info->exportObjectType != VK_EXPORT_METAL_OBJECT_TYPE_METAL_DEVICE_BIT_EXT) &&
182 (export_metal_object_info->exportObjectType != VK_EXPORT_METAL_OBJECT_TYPE_METAL_COMMAND_QUEUE_BIT_EXT)) {
183 skip |= LogError(instance, "VUID-VkInstanceCreateInfo-pNext-06779",
184 "vkCreateInstance(): The pNext chain contains a VkExportMetalObjectCreateInfoEXT whose "
185 "exportObjectType = %s, but only VkExportMetalObjectCreateInfoEXT structs with exportObjectType of "
186 "VK_EXPORT_METAL_OBJECT_TYPE_METAL_DEVICE_BIT_EXT or "
187 "VK_EXPORT_METAL_OBJECT_TYPE_METAL_COMMAND_QUEUE_BIT_EXT are allowed",
188 string_VkExportMetalObjectTypeFlagBitsEXT(export_metal_object_info->exportObjectType));
189 }
190 export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(export_metal_object_info->pNext);
191 }
192#endif // VK_USE_PLATFORM_METAL_EXT
193
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700194 return skip;
195}
196
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700197void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700198 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
199 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700200 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
201 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700202 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700203 this->instance_extensions = instance_data->instance_extensions;
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700204}
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600205
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700206void StatelessValidation::CommonPostCallRecordEnumeratePhysicalDevice(const VkPhysicalDevice *phys_devices, const int count) {
207 // Assume phys_devices is valid
208 assert(phys_devices);
209 for (int i = 0; i < count; ++i) {
210 const auto &phys_device = phys_devices[i];
211 if (0 == physical_device_properties_map.count(phys_device)) {
212 auto phys_dev_props = new VkPhysicalDeviceProperties;
213 DispatchGetPhysicalDeviceProperties(phys_device, phys_dev_props);
214 physical_device_properties_map[phys_device] = phys_dev_props;
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600215
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700216 // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state
217 uint32_t ext_count = 0;
Jeremy Gebbencbf22862021-03-03 12:01:22 -0700218 layer_data::unordered_set<std::string> dev_exts_enumerated{};
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700219 std::vector<VkExtensionProperties> ext_props{};
220 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, nullptr);
221 ext_props.resize(ext_count);
222 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, ext_props.data());
223 for (uint32_t j = 0; j < ext_count; j++) {
224 dev_exts_enumerated.insert(ext_props[j].extensionName);
225 }
226 device_extensions_enumerated[phys_device] = std::move(dev_exts_enumerated);
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600227 }
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700228 }
229}
230
231void StatelessValidation::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
232 VkPhysicalDevice *pPhysicalDevices, VkResult result) {
233 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
234 return;
235 }
236
237 if (pPhysicalDeviceCount && pPhysicalDevices) {
238 CommonPostCallRecordEnumeratePhysicalDevice(pPhysicalDevices, *pPhysicalDeviceCount);
239 }
240}
241
242void StatelessValidation::PostCallRecordEnumeratePhysicalDeviceGroups(
243 VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties,
244 VkResult result) {
245 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
246 return;
247 }
248
249 if (pPhysicalDeviceGroupCount && pPhysicalDeviceGroupProperties) {
250 for (uint32_t i = 0; i < *pPhysicalDeviceGroupCount; i++) {
251 const auto &group = pPhysicalDeviceGroupProperties[i];
252 CommonPostCallRecordEnumeratePhysicalDevice(group.physicalDevices, group.physicalDeviceCount);
253 }
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600254 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700255}
256
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600257void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
258 for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) {
259 delete (it->second);
260 it = physical_device_properties_map.erase(it);
261 }
262};
263
ziga-lunarg685d5d62022-05-14 00:38:06 +0200264
265void StatelessValidation::GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
266 VkPhysicalDeviceProperties2 &pProperties) const {
267 if (api_version >= VK_API_VERSION_1_1) {
268 DispatchGetPhysicalDeviceProperties2(physicalDevice, &pProperties);
269 } else if (IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2)) {
270 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &pProperties);
271 }
272}
273
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700274void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700275 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700276 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700277 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700278 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
279 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700280
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700281 // Parmeter validation also uses extension data
282 stateless_validation->device_extensions = this->device_extensions;
283
284 VkPhysicalDeviceProperties device_properties = {};
285 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600286 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700287 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
288
sfricke-samsung45996a42021-09-16 13:45:27 -0700289 if (IsExtEnabled(device_extensions.vk_nv_shading_rate_image)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700290 // Get the needed shading rate image limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700291 auto shading_rate_image_props = LvlInitStruct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
292 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&shading_rate_image_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200293 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700294 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
295 }
296
sfricke-samsung45996a42021-09-16 13:45:27 -0700297 if (IsExtEnabled(device_extensions.vk_nv_mesh_shader)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700298 // Get the needed mesh shader limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700299 auto mesh_shader_props = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesNV>();
300 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200301 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700302 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
303 }
304
sfricke-samsung45996a42021-09-16 13:45:27 -0700305 if (IsExtEnabled(device_extensions.vk_nv_ray_tracing)) {
Jason Macnak5c954952019-07-09 15:46:12 -0700306 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700307 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPropertiesNV>();
308 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200309 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500310 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
311 }
312
sfricke-samsung45996a42021-09-16 13:45:27 -0700313 if (IsExtEnabled(device_extensions.vk_khr_ray_tracing_pipeline)) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500314 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700315 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>();
316 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200317 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500318 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700319 }
320
sfricke-samsung45996a42021-09-16 13:45:27 -0700321 if (IsExtEnabled(device_extensions.vk_khr_acceleration_structure)) {
sourav parmarcd5fb182020-07-17 12:58:44 -0700322 // Get the needed ray tracing acc structure limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700323 auto acc_structure_props = LvlInitStruct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>();
324 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&acc_structure_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200325 GetPhysicalDeviceProperties2(physicalDevice, prop2);
sourav parmarcd5fb182020-07-17 12:58:44 -0700326 phys_dev_ext_props.acc_structure_props = acc_structure_props;
327 }
328
sfricke-samsung45996a42021-09-16 13:45:27 -0700329 if (IsExtEnabled(device_extensions.vk_ext_transform_feedback)) {
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700330 // Get the needed transform feedback limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700331 auto transform_feedback_props = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
332 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&transform_feedback_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200333 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700334 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
335 }
336
sfricke-samsung45996a42021-09-16 13:45:27 -0700337 if (IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor)) {
Piers Daniellcb6d8032021-04-19 18:51:26 -0600338 // Get the needed vertex attribute divisor limits
339 auto vertex_attribute_divisor_props = LvlInitStruct<VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT>();
340 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&vertex_attribute_divisor_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200341 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Piers Daniellcb6d8032021-04-19 18:51:26 -0600342 phys_dev_ext_props.vertex_attribute_divisor_props = vertex_attribute_divisor_props;
343 }
344
sfricke-samsung45996a42021-09-16 13:45:27 -0700345 if (IsExtEnabled(device_extensions.vk_ext_blend_operation_advanced)) {
Piers Daniella7f93b62021-11-20 12:32:04 -0700346 // Get the needed blend operation advanced properties
ziga-lunarga283d022021-08-04 18:35:23 +0200347 auto blend_operation_advanced_props = LvlInitStruct<VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT>();
348 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&blend_operation_advanced_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200349 GetPhysicalDeviceProperties2(physicalDevice, prop2);
ziga-lunarga283d022021-08-04 18:35:23 +0200350 phys_dev_ext_props.blend_operation_advanced_props = blend_operation_advanced_props;
351 }
352
Piers Daniella7f93b62021-11-20 12:32:04 -0700353 if (IsExtEnabled(device_extensions.vk_khr_maintenance4)) {
354 // Get the needed maintenance4 properties
355 auto maintance4_props = LvlInitStruct<VkPhysicalDeviceMaintenance4PropertiesKHR>();
356 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&maintance4_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200357 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Piers Daniella7f93b62021-11-20 12:32:04 -0700358 phys_dev_ext_props.maintenance4_props = maintance4_props;
359 }
360
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800361 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
362
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700363 // Save app-enabled features in this device's validation object
364 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700365 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200366 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
367 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
368 if (features2) {
369 tmp_features2_state.features = features2->features;
370 } else if (pCreateInfo->pEnabledFeatures) {
371 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700372 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200373 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700374 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200375 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700376 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200377 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700378}
379
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700380bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500381 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600382 bool skip = false;
383
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200384 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
385 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
386 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600387 }
388
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700389 // If this device supports VK_KHR_portability_subset, it must be enabled
390 const std::string portability_extension_name("VK_KHR_portability_subset");
391 const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice);
392 const bool portability_supported = dev_extensions.count(portability_extension_name) != 0;
393 bool portability_requested = false;
394
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200395 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
396 skip |=
397 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
398 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
399 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
400 pCreateInfo->ppEnabledExtensionNames[i]);
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700401 if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) {
402 portability_requested = true;
403 }
404 }
405
406 if (portability_supported && !portability_requested) {
407 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451",
408 "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it",
409 report_data->FormatHandle(physicalDevice).c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600410 }
411
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200412 {
aitor-lunargd5301592022-01-05 22:38:16 +0100413 bool maint1 = IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE_1_EXTENSION_NAME));
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700414 bool negative_viewport =
aitor-lunargd5301592022-01-05 22:38:16 +0100415 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
416 if (negative_viewport) {
417 // Only need to check for VK_KHR_MAINTENANCE_1_EXTENSION_NAME if api version is 1.0, otherwise it's deprecated due to
418 // integration into api version 1.1
419 if (api_version >= VK_API_VERSION_1_1) {
420 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-01840",
421 "vkCreateDevice(): VkDeviceCreateInfo->ppEnabledExtensionNames must not include "
422 "VK_AMD_negative_viewport_height if api version is greater than or equal to 1.1.");
423 } else if (maint1) {
424 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
425 "vkCreateDevice(): VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include "
426 "VK_KHR_maintenance1 and VK_AMD_negative_viewport_height.");
427 }
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200428 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600429 }
430
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600431 {
ziga-lunarg9271a7c2021-07-19 16:37:06 +0200432 bool khr_bda =
433 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
434 bool ext_bda =
435 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600436 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700437 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
438 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
439 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600440 }
441 }
442
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600443 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
444 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700445 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600446 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800447 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700448 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800449 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700450 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600451 }
452 }
453
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700454 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500455 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700456 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500457 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
458 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
459 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
460 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700461 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700462 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
463 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
464 skip |= LogError(
465 device,
466 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
467 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
468 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700469 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700470 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -0700471 if (vertex_attribute_divisor_features && (!IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor))) {
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600472 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
473 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
474 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600475 }
476
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700477 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700478 if (vulkan_11_features) {
479 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
480 while (current) {
481 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
482 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
483 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
484 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
485 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
486 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700487 skip |= LogError(
488 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700489 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
490 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
491 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
492 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
493 break;
494 }
495 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
496 }
sfricke-samsungebda6792021-01-16 08:57:52 -0800497
498 // Check features are enabled if matching extension is passed in as well
499 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
500 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
501 if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
502 (vulkan_11_features->shaderDrawParameters == VK_FALSE)) {
503 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800504 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-04476",
sfricke-samsungebda6792021-01-16 08:57:52 -0800505 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.",
506 VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
507 }
508 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700509 }
510
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700511 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700512 if (vulkan_12_features) {
513 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
514 while (current) {
515 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
516 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
517 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
518 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
519 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
520 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
521 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
522 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
523 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
524 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
525 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
526 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
527 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700528 skip |= LogError(
529 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700530 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
531 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
532 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
533 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
534 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
535 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
536 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
537 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
538 break;
539 }
540 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
541 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700542 // Check features are enabled if matching extension is passed in as well
543 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
544 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
545 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
546 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
547 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800548 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02831",
sfricke-samsungabab4632020-05-04 06:51:46 -0700549 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
550 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
551 }
552 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
553 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
Mike Schuchardt9969d022021-12-20 15:51:55 -0800554 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02832",
sfricke-samsungabab4632020-05-04 06:51:46 -0700555 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
556 "is not VK_TRUE.",
557 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
558 }
559 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
560 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
561 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800562 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02833",
sfricke-samsungabab4632020-05-04 06:51:46 -0700563 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
564 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
565 }
566 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
567 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
568 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800569 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02834",
sfricke-samsungabab4632020-05-04 06:51:46 -0700570 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
571 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
572 }
573 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
574 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
575 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
576 skip |=
Mike Schuchardt9969d022021-12-20 15:51:55 -0800577 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02835",
sfricke-samsungabab4632020-05-04 06:51:46 -0700578 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
579 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
580 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
581 }
582 }
ziga-lunarg27f88fd2021-08-01 15:47:30 +0200583 if (vulkan_12_features->bufferDeviceAddress == VK_TRUE) {
584 if (IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))) {
585 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-04748",
586 "vkCreateDevice(): pNext chain includes VkPhysicalDeviceVulkan12Features with bufferDeviceAddress "
587 "set to VK_TRUE and ppEnabledExtensionNames contains VK_EXT_buffer_device_address");
588 }
589 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700590 }
591
Tony-LunarG273f32f2021-09-28 08:56:30 -0600592 const auto *vulkan_13_features = LvlFindInChain<VkPhysicalDeviceVulkan13Features>(pCreateInfo->pNext);
593 if (vulkan_13_features) {
594 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
595 while (current) {
596 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES ||
597 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES ||
598 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES ||
599 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES ||
600 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES ||
601 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES ||
602 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES ||
603 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES ||
604 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES ||
605 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES ||
606 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES ||
607 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES ||
608 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES) {
Nathaniel Cesario7a1f5b02022-06-06 12:32:59 -0600609 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-06532",
610 "vkCreateDevice(): %s structure included in VkPhysicalDeviceVulkan13Features' pNext chain.",
611 string_VkStructureType(current->sType));
Tony-LunarG273f32f2021-09-28 08:56:30 -0600612 break;
613 }
614 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
615 }
616 }
617
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600618 // Validate pCreateInfo->pQueueCreateInfos
619 if (pCreateInfo->pQueueCreateInfos) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600620
621 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700622 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
623 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600624 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700625 skip |=
626 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
627 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
628 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
629 "index value.",
630 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600631 }
632
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700633 if (queue_create_info.pQueuePriorities != nullptr) {
634 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
635 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600636 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700637 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
638 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
639 "] (=%f) is not between 0 and 1 (inclusive).",
640 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600641 }
642 }
643 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700644
645 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700646 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700647 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700648 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700649 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700650 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700651 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700652 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700653 }
Mike Schuchardta9101d32021-11-12 12:24:08 -0800654 if (((queue_create_info.flags & VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) != 0) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700655 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
Mike Schuchardta9101d32021-11-12 12:24:08 -0800656 "vkCreateDevice: pCreateInfo->flags contains VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
657 "protectedMemory feature being enabled as well.");
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700658 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600659 }
660 }
661
sfricke-samsung30a57412020-05-15 21:14:54 -0700662 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700663 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700664 VkBool32 variable_pointers = VK_FALSE;
665 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700666 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700667 variable_pointers = vulkan_11_features->variablePointers;
668 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700669 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700670 variable_pointers = variable_pointers_features->variablePointers;
671 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700672 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700673 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700674 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
675 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
676 }
677
sfricke-samsungfd76c342020-05-29 23:13:43 -0700678 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700679 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700680 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700681 VkBool32 multiview_geometry_shader = VK_FALSE;
682 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700683 if (vulkan_11_features) {
684 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700685 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
686 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700687 } else if (multiview_features) {
688 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700689 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
690 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700691 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700692 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700693 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
694 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
695 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700696 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700697 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
698 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
699 }
700
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600701 return skip;
702}
703
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500704bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700705 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700706 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
707 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
708 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600709 }
710
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700711 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600712}
713
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700714bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500715 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100716 bool skip = false;
717
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600718 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700719 skip |=
720 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600721
722 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
723 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
724 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
725 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700726 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
727 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
728 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600729 }
730
731 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
732 // queueFamilyIndexCount uint32_t values
733 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700734 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
735 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
736 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
737 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600738 }
739 }
740
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700741 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
742 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
743 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
744 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
745 }
746
747 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
748 skip |=
749 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
750 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
751 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
752 }
753
754 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
755 skip |=
756 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
757 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
758 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
759 }
760
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600761 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
762 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
763 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
764 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700765 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
766 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
767 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600768 }
Piers Daniella7f93b62021-11-20 12:32:04 -0700769
770 const auto *maintenance4_features = LvlFindInChain<VkPhysicalDeviceMaintenance4FeaturesKHR>(device_createinfo_pnext);
771 if (maintenance4_features && maintenance4_features->maintenance4) {
772 if (pCreateInfo->size > phys_dev_ext_props.maintenance4_props.maxBufferSize) {
773 skip |= LogError(device, "VUID-VkBufferCreateInfo-size-06409",
774 "vkCreateBuffer: pCreateInfo->size is larger than the maximum allowed buffer size "
775 "VkPhysicalDeviceMaintenance4Properties.maxBufferSize");
776 }
777 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600778 }
779
780 return skip;
781}
782
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700783bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500784 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600785 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600786
787 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800788 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700789 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600790 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
791 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
792 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
793 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700794 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
795 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
796 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600797 }
798
799 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
800 // queueFamilyIndexCount uint32_t values
801 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700802 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
803 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
804 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
805 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600806 }
807 }
808
Dave Houlton413a6782018-05-22 13:01:54 -0600809 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700810 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600811 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700812 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600813 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700814 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600815
Dave Houlton413a6782018-05-22 13:01:54 -0600816 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700817 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600818 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700819 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600820
Dave Houlton130c0212018-01-29 13:39:56 -0700821 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700822 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
823 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700824 skip |= LogError(
825 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600826 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
827 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700828 }
829
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600830 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100831 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
832 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700833 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
834 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
835 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600836 }
837
838 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700839 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100840 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700841 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
842 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
843 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
844 ") are not equal.",
845 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100846 }
847
848 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700849 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
850 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
851 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
852 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100853 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600854 }
855
856 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700857 skip |= LogError(
858 device, "VUID-VkImageCreateInfo-imageType-00957",
859 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600860 }
861 }
862
Dave Houlton130c0212018-01-29 13:39:56 -0700863 // 3D image may have only 1 layer
864 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700865 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
866 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700867 }
868
Dave Houlton130c0212018-01-29 13:39:56 -0700869 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
870 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
871 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
872 // At least one of the legal attachment bits must be set
873 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700874 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
875 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700876 }
877 // No flags other than the legal attachment bits may be set
878 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
879 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700880 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
881 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700882 }
883 }
884
Jeff Bolzef40fec2018-09-01 22:04:34 -0500885 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700886 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500887 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700888 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700889 ? static_cast<uint32_t>(ceil(log2(max_dim)))
890 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
891 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600892 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700893 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
894 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
895 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600896 }
897
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700898 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700899 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
900 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
901 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600902 }
903
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700904 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700905 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
906 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
907 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100908 }
909
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700910 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700911 skip |= LogError(
912 device, "VUID-VkImageCreateInfo-flags-01924",
913 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
914 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
915 }
916
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600917 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
918 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700919 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
920 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700921 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
922 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
923 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600924 }
925
926 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700927 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600928 // Linear tiling is unsupported
929 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700930 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700931 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
932 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600933 }
934
935 // Sparse 1D image isn't valid
936 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700937 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
938 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600939 }
940
941 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700942 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700943 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
944 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
945 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600946 }
947
948 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700949 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700950 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
951 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
952 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600953 }
954
955 // Multi-sample 2D image when device doesn't support it
956 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700957 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600958 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700959 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
960 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
961 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700962 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600963 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700964 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
965 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
966 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700967 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600968 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700969 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
970 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
971 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700972 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600973 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700974 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
975 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
976 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600977 }
978 }
979 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500980
Jeff Bolz9af91c52018-09-01 21:53:57 -0500981 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
982 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700983 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
984 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
985 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500986 }
987 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700988 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
989 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
990 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500991 }
992 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700993 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
994 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
995 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500996 }
997 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500998
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700999 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001000 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001001 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
1002 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
1003 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -05001004 }
1005
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001006 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001007 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
1008 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -08001009 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
1010 "depth/stencil format.",
1011 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -05001012 }
1013
Dave Houlton142c4cb2018-10-17 15:04:41 -06001014 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001015 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
1016 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
1017 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
1018 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001019 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001020 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001021 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
1022 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
1023 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
1024 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -05001025 }
1026 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05001027
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001028 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -08001029 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -07001030 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
1031 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -08001032 "format (%s) must be a depth or depth/stencil format.",
1033 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -07001034 }
1035
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001036 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05001037 if (image_stencil_struct != nullptr) {
1038 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
1039 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
1040 // No flags other than the legal attachment bits may be set
1041 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
1042 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001043 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
1044 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
1045 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
1046 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -05001047 }
1048 }
1049
sfricke-samsung61a57c02021-01-10 21:35:12 -08001050 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -05001051 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
1052 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001053 skip |=
1054 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
1055 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1056 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%" PRIu32
1057 ") exceeds device "
1058 "maxFramebufferWidth (%" PRIu32 ")",
1059 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -05001060 }
1061
1062 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001063 skip |=
1064 LogError(device, "VUID-VkImageCreateInfo-format-02537",
1065 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1066 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%" PRIu32
1067 ") exceeds device "
1068 "maxFramebufferHeight (%" PRIu32 ")",
1069 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -05001070 }
1071 }
1072
1073 if (!physical_device_features.shaderStorageImageMultisample &&
1074 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1075 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1076 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001077 LogError(device, "VUID-VkImageCreateInfo-format-02538",
1078 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1079 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
1080 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -05001081 }
1082
1083 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
1084 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001085 skip |= LogError(
1086 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001087 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1088 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1089 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1090 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
1091 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001092 skip |= LogError(
1093 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001094 "vkCreateImage(): Depth-stencil image in which usage does not include "
1095 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1096 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1097 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1098 }
1099
1100 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
1101 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001102 skip |= LogError(
1103 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001104 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1105 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1106 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1107 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1108 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001109 skip |= LogError(
1110 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001111 "vkCreateImage(): Depth-stencil image in which usage does not include "
1112 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1113 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1114 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1115 }
1116 }
1117 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001118
1119 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1120 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1121 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1122 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1123 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1124 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001125
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001126 std::vector<uint64_t> image_create_drm_format_modifiers;
sfricke-samsung45996a42021-09-16 13:45:27 -07001127 if (IsExtEnabled(device_extensions.vk_ext_image_drm_format_modifier)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001128 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1129 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001130 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1131 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1132 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1133 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1134 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1135 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1136 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001137 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001138 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1139 } else if (drm_format_mod_list != nullptr) {
1140 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1141 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1142 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001143 }
1144 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1145 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1146 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1147 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1148 "in the pNext chain");
1149 }
1150 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001151
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001152 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001153 bool image_create_maybe_linear = false;
1154 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1155 image_create_maybe_linear = true;
1156 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1157 image_create_maybe_linear = false;
1158 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1159 image_create_maybe_linear =
1160 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001161 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001162 }
1163
1164 // If multi-sample, validate type, usage, tiling and mip levels.
1165 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001166 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001167 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1168 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1169 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1170 }
1171
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001172 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001173 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1174 image_create_maybe_linear)) {
1175 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1176 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1177 }
1178
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001179 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1180 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1181 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1182 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1183 "imageType must be VK_IMAGE_TYPE_2D.");
1184 }
1185 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1186 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1187 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1188 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1189 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001190 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001191 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001192 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1193 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1194 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1195 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1196 }
1197 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1198 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1199 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1200 "imageType must be VK_IMAGE_TYPE_2D.");
1201 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001202 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001203 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1204 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1205 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1206 }
1207 if (pCreateInfo->mipLevels != 1) {
1208 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001209 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%" PRIu32
1210 ") must be 1.",
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001211 pCreateInfo->mipLevels);
1212 }
1213 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001214
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001215 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001216 if (swapchain_create_info != nullptr) {
1217 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1218 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1219 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1220 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1221 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1222 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1223
1224 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1225 // also implicitly forces the check above that extent.depth is 1
1226 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1227 string_VkImageType(pCreateInfo->imageType));
1228 }
1229 if (pCreateInfo->mipLevels != 1) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001230 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %" PRIu32 ".", base_message,
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001231 pCreateInfo->mipLevels);
1232 }
1233 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1234 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1235 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1236 }
1237 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1238 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1239 base_message, string_VkImageTiling(pCreateInfo->tiling));
1240 }
1241 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1242 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1243 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1244 }
1245 const VkImageCreateFlags valid_flags =
1246 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001247 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001248 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001249 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001250 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001251 }
1252 }
1253 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001254
1255 // If Chroma subsampled format ( _420_ or _422_ )
1256 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1257 skip |=
1258 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1259 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1260 ") must be a multiple of 2.",
1261 string_VkFormat(image_format), pCreateInfo->extent.width);
1262 }
1263 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1264 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1265 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1266 ") must be a multiple of 2.",
1267 string_VkFormat(image_format), pCreateInfo->extent.height);
1268 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001269
1270 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1271 if (format_list_info) {
1272 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1273 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1274 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1275 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001276 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32 ") must be 0 or 1.",
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001277 viewFormatCount);
1278 }
1279 // Check if viewFormatCount is not zero that it is all compatible
1280 for (uint32_t i = 0; i < viewFormatCount; i++) {
Mike Schuchardtb0608492022-04-05 18:52:48 -07001281 const bool class_compatible =
1282 FormatCompatibilityClass(format_list_info->pViewFormats[i]) == FormatCompatibilityClass(image_format);
1283 if (!class_compatible) {
1284 if (image_flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT) {
1285 const bool size_compatible =
1286 FormatIsCompressed(format_list_info->pViewFormats[i])
1287 ? false
1288 : FormatElementSize(format_list_info->pViewFormats[i]) == FormatElementSize(image_format);
1289 if (!size_compatible) {
1290 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06722",
1291 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
1292 "] (%s) and VkImageCreateInfo::format (%s) are not compatible or size-compatible.",
1293 i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format));
1294 }
1295 } else {
1296 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06722",
1297 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
1298 "] (%s) and VkImageCreateInfo::format (%s) are not compatible.",
1299 i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format));
1300 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001301 }
1302 }
1303 }
Younggwan Kimff6495a2021-12-16 20:28:45 +00001304
1305 const auto image_compression_control = LvlFindInChain<VkImageCompressionControlEXT>(pCreateInfo->pNext);
1306 if (image_compression_control) {
1307 constexpr VkImageCompressionFlagsEXT AllVkImageCompressionFlagBitsEXT =
1308 (VK_IMAGE_COMPRESSION_DEFAULT_EXT | VK_IMAGE_COMPRESSION_FIXED_RATE_DEFAULT_EXT |
1309 VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT | VK_IMAGE_COMPRESSION_DISABLED_EXT);
1310 skip |= validate_flags("vkCreateImage", "VkImageCompressionControlEXT::flags", "VkImageCompressionFlagsEXT",
1311 AllVkImageCompressionFlagBitsEXT, image_compression_control->flags, kRequiredSingleBit,
1312 "VUID-VkImageCompressionControlEXT-flags-06747");
1313
1314 if (image_compression_control->flags == VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT &&
1315 !image_compression_control->pFixedRateFlags) {
1316 skip |= LogError(
1317 device, "VUID-VkImageCompressionControlEXT-flags-06748",
1318 "VkImageCompressionControlEXT::pFixedRateFlags is nullptr even though VkImageCompressionControlEXT::flags are %s",
1319 string_VkImageCompressionFlagsEXT(image_compression_control->flags).c_str());
1320 }
1321 }
Tony-LunarG115f89d2022-06-15 10:53:22 -06001322#ifdef VK_USE_PLATFORM_METAL_EXT
1323 auto export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(pCreateInfo->pNext);
1324 while (export_metal_object_info) {
1325 if ((export_metal_object_info->exportObjectType != VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT) &&
1326 (export_metal_object_info->exportObjectType != VK_EXPORT_METAL_OBJECT_TYPE_METAL_IOSURFACE_BIT_EXT)) {
1327 skip |=
1328 LogError(device, "VUID-VkImageCreateInfo-pNext-06783",
1329 "vkCreateImage(): The pNext chain contains a VkExportMetalObjectCreateInfoEXT whose "
1330 "exportObjectType = %s, but only VkExportMetalObjectCreateInfoEXT structs with exportObjectType of "
1331 "VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT or VK_EXPORT_METAL_OBJECT_TYPE_METAL_IOSURFACE_BIT_EXT are allowed",
1332 string_VkExportMetalObjectTypeFlagBitsEXT(export_metal_object_info->exportObjectType));
1333 }
1334 export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(export_metal_object_info->pNext);
1335 }
1336 auto import_metal_texture_info = LvlFindInChain<VkImportMetalTextureInfoEXT>(pCreateInfo->pNext);
1337 while (import_metal_texture_info) {
1338 if ((import_metal_texture_info->plane != VK_IMAGE_ASPECT_PLANE_0_BIT) &&
1339 (import_metal_texture_info->plane != VK_IMAGE_ASPECT_PLANE_1_BIT) &&
1340 (import_metal_texture_info->plane != VK_IMAGE_ASPECT_PLANE_2_BIT)) {
1341 skip |=
1342 LogError(device, "VUID-VkImageCreateInfo-pNext-06784",
1343 "vkCreateImage(): The pNext chain contains a VkImportMetalTextureInfoEXT whose "
1344 "plane = %s, but only VK_IMAGE_ASPECT_PLANE_0_BIT, VK_IMAGE_ASPECT_PLANE_1_BIT, or VK_IMAGE_ASPECT_PLANE_2_BIT are allowed",
1345 string_VkImageAspectFlags(import_metal_texture_info->plane).c_str());
1346 }
1347 auto format_plane_count = FormatPlaneCount(pCreateInfo->format);
1348 if ((format_plane_count <= 1) && (import_metal_texture_info->plane != VK_IMAGE_ASPECT_PLANE_0_BIT)) {
1349 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06785",
1350 "vkCreateImage(): The pNext chain contains a VkImportMetalTextureInfoEXT whose "
1351 "plane = %s, but only VK_IMAGE_ASPECT_PLANE_0_BIT is allowed for an image created with format %s, which is not multiplaner",
1352 string_VkImageAspectFlags(import_metal_texture_info->plane).c_str(),
1353 string_VkFormat(pCreateInfo->format));
1354 }
1355 if ((format_plane_count == 2) && (import_metal_texture_info->plane == VK_IMAGE_ASPECT_PLANE_2_BIT)) {
1356 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06786",
1357 "vkCreateImage(): The pNext chain contains a VkImportMetalTextureInfoEXT whose "
1358 "plane == VK_IMAGE_ASPECT_PLANE_2_BIT, which is not allowed for an image created with format %s, "
1359 "which has only 2 planes",
1360 string_VkFormat(pCreateInfo->format));
1361 }
1362 import_metal_texture_info = LvlFindInChain<VkImportMetalTextureInfoEXT>(import_metal_texture_info->pNext);
1363 }
1364#endif // VK_USE_PLATFORM_METAL_EXT
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001365 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001366
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001367 return skip;
1368}
1369
Jeff Bolz99e3f632020-03-24 22:59:22 -05001370bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1371 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1372 bool skip = false;
1373
1374 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001375 // Validate feature set if using CUBE_ARRAY
1376 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1377 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1378 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1379 "enabling the imageCubeArray feature.");
1380 }
1381
Jeff Bolz99e3f632020-03-24 22:59:22 -05001382 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1383 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1384 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001385 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1386 ") must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001387 pCreateInfo->subresourceRange.layerCount);
1388 }
1389 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001390 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02961",
1391 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1392 ") must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1393 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001394 }
1395 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001396
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001397 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -07001398 if (IsExtEnabled(device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001399 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1400 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1401 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1402 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1403 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1404 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1405 }
sfricke-samsunge3086292021-11-18 23:02:35 -08001406 if ((FormatIsCompressed_ASTC_LDR(pCreateInfo->format) == false) &&
1407 (FormatIsCompressed_ASTC_HDR(pCreateInfo->format) == false)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001408 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1409 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1410 "not an ASTC format.",
1411 string_VkFormat(pCreateInfo->format));
1412 }
1413 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001414
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001415 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001416 if (ycbcr_conversion != nullptr) {
1417 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1418 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1419 skip |= LogError(
1420 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1421 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1422 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1423 "r swizzle = %s\n"
1424 "g swizzle = %s\n"
1425 "b swizzle = %s\n"
1426 "a swizzle = %s\n",
1427 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1428 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1429 }
1430 }
1431 }
Tony-LunarG115f89d2022-06-15 10:53:22 -06001432#ifdef VK_USE_PLATFORM_METAL_EXT
1433 skip |= ExportMetalObjectsPNextUtil(
1434 VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT, "VUID-VkImageViewCreateInfo-pNext-06787",
1435 "vkCreateImageView():", "VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT", pCreateInfo->pNext);
1436#endif // VK_USE_PLATFORM_METAL_EXT
Jeff Bolz99e3f632020-03-24 22:59:22 -05001437 }
1438 return skip;
1439}
1440
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001441bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001442 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001443 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001444
1445 // Note: for numerical correctness
1446 // - float comparisons should expect NaN (comparison always false).
1447 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1448
1449 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001450 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001451 if (v1_f <= 0.0f) return true;
1452
1453 float intpart;
1454 const float fract = modff(v1_f, &intpart);
1455
1456 assert(std::numeric_limits<float>::radix == 2);
1457 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1458 if (intpart >= u32_max_plus1) return false;
1459
1460 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001461 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001462 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001463 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001464 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001465 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001466 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001467 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001468 };
1469
1470 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1471 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1472 return (v1_f <= v2_f);
1473 };
1474
1475 // width
1476 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001477 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001478
1479 if (!(viewport.width > 0.0f)) {
1480 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001481 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1482 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001483 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1484 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001485 skip |= LogError(object, "VUID-VkViewport-width-01771",
1486 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1487 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001488 }
1489
1490 // height
1491 bool height_healthy = true;
sfricke-samsung45996a42021-09-16 13:45:27 -07001492 const bool negative_height_enabled =
1493 IsExtEnabled(device_extensions.vk_khr_maintenance1) || IsExtEnabled(device_extensions.vk_amd_negative_viewport_height);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001494 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001495
1496 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1497 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001498 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1499 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001500 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1501 height_healthy = false;
1502
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001503 skip |= LogError(object, "VUID-VkViewport-height-01773",
1504 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1505 ").",
1506 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001507 }
1508
1509 // x
1510 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001511 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001512 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001513 skip |= LogError(object, "VUID-VkViewport-x-01774",
1514 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1515 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001516 }
1517
1518 // x + width
1519 if (x_healthy && width_healthy) {
1520 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001521 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001522 skip |= LogError(
1523 object, "VUID-VkViewport-x-01232",
1524 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1525 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1526 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001527 }
1528 }
1529
1530 // y
1531 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001532 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001533 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001534 skip |= LogError(object, "VUID-VkViewport-y-01775",
1535 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1536 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001537 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001538 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001539 skip |= LogError(object, "VUID-VkViewport-y-01776",
1540 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1541 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001542 }
1543
1544 // y + height
1545 if (y_healthy && height_healthy) {
1546 const float boundary = viewport.y + viewport.height;
1547
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001548 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001549 skip |= LogError(object, "VUID-VkViewport-y-01233",
1550 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1551 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1552 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001553 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001554 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001555 LogError(object, "VUID-VkViewport-y-01777",
1556 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1557 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1558 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001559 }
1560 }
1561
sfricke-samsungfd06d422021-01-22 02:17:21 -08001562 // The extension was not created with a feature bit whichs prevents displaying the 2 variations of the VUIDs
sfricke-samsung45996a42021-09-16 13:45:27 -07001563 if (!IsExtEnabled(device_extensions.vk_ext_depth_range_unrestricted)) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001564 // minDepth
1565 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001566 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001567 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001568 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1569 "[0.0, 1.0] range.",
1570 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001571 }
1572
1573 // maxDepth
1574 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001575 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001576 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001577 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1578 "[0.0, 1.0] range.",
1579 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001580 }
1581 }
1582
1583 return skip;
1584}
1585
Dave Houlton142c4cb2018-10-17 15:04:41 -06001586struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001587 VkShadingRatePaletteEntryNV shadingRate;
1588 uint32_t width;
1589 uint32_t height;
1590};
1591
1592// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001593static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001594 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1595 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1596 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1597 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1598 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1599 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001600};
1601
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001602bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001603 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001604
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001605 SampleOrderInfo *sample_order_info;
1606 uint32_t info_idx = 0;
1607 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1608 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1609 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001610 break;
1611 }
1612 }
1613
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001614 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001615 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1616 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1617 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001618 return skip;
1619 }
1620
Dave Houlton142c4cb2018-10-17 15:04:41 -06001621 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001622 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001623 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1624 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1625 ") must "
1626 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1627 "is set in framebufferNoAttachmentsSampleCounts.",
1628 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001629 }
1630
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001631 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001632 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1633 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1634 ") must "
1635 "be equal to the product of sampleCount (=%" PRIu32
1636 "), the fragment width for shadingRate "
1637 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001638 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001639 }
1640
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001641 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001642 skip |= LogError(
1643 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001644 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1645 ") must "
1646 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001647 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001648 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001649
1650 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001651 // the first width*height*sampleCount bits to all be set. Note: There is no
1652 // guarantee that 64 bits is enough, but practically it's unlikely for an
1653 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001654 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001655 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001656 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001657 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1658 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001659 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1660 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001661 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001662 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001663 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1664 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001665 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001666 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001667 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1668 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001669 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001670 uint32_t idx =
1671 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1672 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001673 }
1674
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001675 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1676 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001677 skip |= LogError(
1678 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001679 "The array pSampleLocations must contain exactly one entry for "
1680 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001681 }
1682
1683 return skip;
1684}
1685
sfricke-samsung51303fb2021-05-09 19:09:13 -07001686bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1687 const VkAllocationCallbacks *pAllocator,
1688 VkPipelineLayout *pPipelineLayout) const {
1689 bool skip = false;
1690 // Validate layout count against device physical limit
1691 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1692 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001693 "vkCreatePipelineLayout(): setLayoutCount (%" PRIu32
1694 ") exceeds physical device maxBoundDescriptorSets limit (%" PRIu32 ").",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001695 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1696 }
1697
Nathaniel Cesario73c994c2022-05-26 23:07:34 -06001698 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library)) {
Nathaniel Cesariodb38b7a2022-03-10 22:16:51 -07001699 for (uint32_t i = 0; i < pCreateInfo->setLayoutCount; ++i) {
1700 if (!pCreateInfo->pSetLayouts[i]) {
Nathaniel Cesario73c994c2022-05-26 23:07:34 -06001701 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-pSetLayouts-06561",
1702 "vkCreatePipelineLayout(): pSetLayouts[%" PRIu32
1703 "] is VK_NULL_HANDLE, but VK_EXT_graphics_pipeline_library is not enabled.",
1704 i);
Nathaniel Cesariodb38b7a2022-03-10 22:16:51 -07001705 }
1706 }
1707 }
1708
sfricke-samsung51303fb2021-05-09 19:09:13 -07001709 // Validate Push Constant ranges
1710 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1711 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1712 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1713 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1714 // Check that offset + size don't exceed the max.
1715 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1716 if (offset >= max_push_constants_size) {
1717 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001718 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1719 ") that exceeds this "
1720 "device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001721 i, offset, max_push_constants_size);
1722 }
1723 if (size > max_push_constants_size - offset) {
1724 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001725 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "] offset (%" PRIu32
1726 ") and size (%" PRIu32
1727 ") "
1728 "together exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001729 i, offset, size, max_push_constants_size);
1730 }
1731
1732 // size needs to be non-zero and a multiple of 4.
1733 if (size == 0) {
1734 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001735 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1736 ") is not greater than zero.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001737 i, size);
1738 }
1739 if (size & 0x3) {
1740 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001741 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1742 ") is not a multiple of 4.",
1743 i, size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001744 }
1745
1746 // offset needs to be a multiple of 4.
1747 if ((offset & 0x3) != 0) {
1748 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001749 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1750 ") is not a multiple of 4.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001751 i, offset);
1752 }
1753 }
1754
1755 // 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.
1756 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1757 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1758 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001759 skip |=
1760 LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1761 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %" PRIu32 " and %" PRIu32 ".", i, j);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001762 }
1763 }
1764 }
1765 return skip;
1766}
1767
ziga-lunargc6341372021-07-28 12:57:42 +02001768bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1769 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1770 bool skip = false;
1771
1772 const auto *required_subgroup_size_features =
1773 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1774
1775 if (required_subgroup_size_features) {
1776 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1777 skip |= LogError(
1778 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1779 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1780 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1781 func_name, msg, pCreateInfo->flags);
1782 }
1783 }
1784
1785 return skip;
1786}
1787
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001788bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1789 uint32_t createInfoCount,
1790 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1791 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001792 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001793 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001794
1795 if (pCreateInfos != nullptr) {
1796 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001797 bool has_dynamic_viewport = false;
1798 bool has_dynamic_scissor = false;
1799 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001800 bool has_dynamic_depth_bias = false;
1801 bool has_dynamic_blend_constant = false;
1802 bool has_dynamic_depth_bounds = false;
1803 bool has_dynamic_stencil_compare = false;
1804 bool has_dynamic_stencil_write = false;
1805 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001806 bool has_dynamic_viewport_w_scaling_nv = false;
1807 bool has_dynamic_discard_rectangle_ext = false;
1808 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001809 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001810 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001811 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001812 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001813 bool has_dynamic_cull_mode = false;
1814 bool has_dynamic_front_face = false;
1815 bool has_dynamic_primitive_topology = false;
1816 bool has_dynamic_viewport_with_count = false;
1817 bool has_dynamic_scissor_with_count = false;
1818 bool has_dynamic_vertex_input_binding_stride = false;
1819 bool has_dynamic_depth_test_enable = false;
1820 bool has_dynamic_depth_write_enable = false;
1821 bool has_dynamic_depth_compare_op = false;
1822 bool has_dynamic_depth_bounds_test_enable = false;
1823 bool has_dynamic_stencil_test_enable = false;
1824 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001825 bool has_patch_control_points = false;
1826 bool has_rasterizer_discard_enable = false;
1827 bool has_depth_bias_enable = false;
1828 bool has_logic_op = false;
1829 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001830 bool has_dynamic_vertex_input = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001831
1832 // Create a copy of create_info and set non-included sub-state to null
1833 auto create_info = pCreateInfos[i];
1834 const auto *graphics_lib_info = LvlFindInChain<VkGraphicsPipelineLibraryCreateInfoEXT>(create_info.pNext);
1835 if (graphics_lib_info) {
Nathaniel Cesariobcb79682022-03-31 21:13:52 -06001836 // TODO (ncesario) Remove this once GPU-AV and debug printf is supported with pipeline libraries
1837 if (enabled[gpu_validation]) {
1838 skip |=
1839 LogError(device, kVUIDUndefined, "GPU-AV with VK_EXT_graphics_pipeline_library is not currently supported");
1840 }
1841 if (enabled[gpu_validation]) {
1842 skip |= LogError(device, kVUIDUndefined,
1843 "Debug printf with VK_EXT_graphics_pipeline_library is not currently supported");
1844 }
1845
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001846 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_VERTEX_INPUT_INTERFACE_BIT_EXT)) {
1847 create_info.pVertexInputState = nullptr;
1848 create_info.pInputAssemblyState = nullptr;
1849 }
1850 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT)) {
1851 create_info.pViewportState = nullptr;
1852 create_info.pRasterizationState = nullptr;
1853 create_info.pTessellationState = nullptr;
1854 }
1855 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT)) {
1856 create_info.pDepthStencilState = nullptr;
1857 }
1858 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT)) {
1859 create_info.pColorBlendState = nullptr;
1860 }
1861 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT |
1862 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) {
1863 create_info.pMultisampleState = nullptr;
1864 }
1865 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT |
1866 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT))) {
1867 create_info.layout = VK_NULL_HANDLE;
1868 }
1869 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT |
1870 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT |
1871 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) {
1872 create_info.renderPass = VK_NULL_HANDLE;
1873 create_info.subpass = 0;
1874 }
1875 }
1876
sjfricke69877a72022-08-10 09:20:01 +09001877 // Values needed from either dynamic rendering or the subpass description
1878 uint32_t color_attachment_count = 0;
1879
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001880 if (!create_info.renderPass) {
1881 if (create_info.pColorBlendState && create_info.pMultisampleState) {
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001882 const auto rendering_struct = LvlFindInChain<VkPipelineRenderingCreateInfo>(create_info.pNext);
ziga-lunarg97584c32022-04-22 14:33:37 +02001883 // Pipeline has fragment output state
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001884 if (rendering_struct) {
sjfricke69877a72022-08-10 09:20:01 +09001885 color_attachment_count = rendering_struct->colorAttachmentCount;
1886
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001887 if ((rendering_struct->depthAttachmentFormat != VK_FORMAT_UNDEFINED)) {
1888 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "stencilAttachmentFormat", "VkFormat",
1889 AllVkFormatEnums, rendering_struct->stencilAttachmentFormat,
1890 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06583");
Nathaniel Cesarioe77320e2022-04-11 17:32:33 -06001891
1892 if (!FormatHasDepth(rendering_struct->depthAttachmentFormat)) {
1893 skip |= LogError(
1894 device, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06587",
1895 "vkCreateGraphicsPipelines() pCreateInfos[%" PRIu32
1896 "]: VkPipelineRenderingCreateInfo::depthAttachmentFormat (%s) does not have a depth aspect.",
1897 i, string_VkFormat(rendering_struct->depthAttachmentFormat));
1898 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001899 }
1900
1901 if ((rendering_struct->stencilAttachmentFormat != VK_FORMAT_UNDEFINED)) {
1902 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "stencilAttachmentFormat", "VkFormat",
1903 AllVkFormatEnums, rendering_struct->stencilAttachmentFormat,
1904 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06584");
Nathaniel Cesarioe77320e2022-04-11 17:32:33 -06001905 if (!FormatHasStencil(rendering_struct->stencilAttachmentFormat)) {
Nathaniel Cesario1ba7ca52022-04-18 12:35:00 -06001906 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06588",
1907 "vkCreateGraphicsPipelines() pCreateInfos[%" PRIu32
1908 "]: VkPipelineRenderingCreateInfo::stencilAttachmentFormat (%s) does not have a "
1909 "stencil aspect.",
1910 i, string_VkFormat(rendering_struct->stencilAttachmentFormat));
Nathaniel Cesarioe77320e2022-04-11 17:32:33 -06001911 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001912 }
Nathaniel Cesario45efaac2022-04-11 17:04:33 -06001913
sjfricke69877a72022-08-10 09:20:01 +09001914 if (color_attachment_count != 0) {
Nathaniel Cesario45efaac2022-04-11 17:04:33 -06001915 skip |= validate_ranged_enum_array(
1916 "VkPipelineRenderingCreateInfo", "VUID-VkGraphicsPipelineCreateInfo-renderPass-06579",
1917 "colorAttachmentCount", "pColorAttachmentFormats", "VkFormat", AllVkFormatEnums,
sjfricke69877a72022-08-10 09:20:01 +09001918 color_attachment_count, rendering_struct->pColorAttachmentFormats, true, true);
Nathaniel Cesario45efaac2022-04-11 17:04:33 -06001919 }
ziga-lunarg97584c32022-04-22 14:33:37 +02001920
1921 if (rendering_struct->pColorAttachmentFormats) {
sjfricke69877a72022-08-10 09:20:01 +09001922 for (uint32_t j = 0; j < color_attachment_count; ++j) {
ziga-lunarg97584c32022-04-22 14:33:37 +02001923 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "pColorAttachmentFormats", "VkFormat",
1924 AllVkFormatEnums, rendering_struct->pColorAttachmentFormats[j],
1925 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06580");
1926 }
1927 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001928 }
ziga-lunarg47258542022-04-22 17:40:43 +02001929
1930 // VkAttachmentSampleCountInfoAMD == VkAttachmentSampleCountInfoNV
1931 auto attachment_sample_count_info = LvlFindInChain<VkAttachmentSampleCountInfoAMD>(create_info.pNext);
1932 if (attachment_sample_count_info && attachment_sample_count_info->pColorAttachmentSamples) {
sjfricke69877a72022-08-10 09:20:01 +09001933 color_attachment_count = attachment_sample_count_info->colorAttachmentCount;
1934
1935 for (uint32_t j = 0; j < color_attachment_count; ++j) {
ziga-lunarg47258542022-04-22 17:40:43 +02001936 skip |= validate_flags("vkCreateGraphicsPipelines",
1937 ParameterName("VkAttachmentSampleCountInfoAMD->pColorAttachmentSamples"),
1938 "VkSampleCountFlagBits", AllVkSampleCountFlagBits,
1939 attachment_sample_count_info->pColorAttachmentSamples[j], kRequiredFlags,
1940 "VUID-VkGraphicsPipelineCreateInfo-pColorAttachmentSamples-06592");
1941 }
1942 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001943 }
1944 }
1945
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001946 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library)) {
1947 if (create_info.stageCount == 0) {
1948 skip |=
1949 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stageCount-06604",
1950 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "].stageCount is 0, but %s is not enabled", i,
1951 VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
1952 }
1953 // TODO while PRIu32 should probably be used instead of %i below, %i is necessary due to
1954 // ParameterName::IndexFormatSpecifier
1955 skip |= validate_struct_type_array(
1956 "vkCreateGraphicsPipelines", ParameterName("pCreateInfos[%i].stageCount", ParameterName::IndexVector{i}),
1957 ParameterName("pCreateInfos[%i].pStages", ParameterName::IndexVector{i}),
sjfricke69877a72022-08-10 09:20:01 +09001958 "VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO", create_info.stageCount, create_info.pStages,
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001959 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, true, true,
1960 "VUID-VkPipelineShaderStageCreateInfo-sType-sType", "VUID-VkGraphicsPipelineCreateInfo-pStages-06600",
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06001961 "VUID-VkGraphicsPipelineCreateInfo-pStages-06600");
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001962 skip |= validate_struct_type("vkCreateGraphicsPipelines",
1963 ParameterName("pCreateInfos[%i].pRasterizationState", ParameterName::IndexVector{i}),
1964 "VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO",
sjfricke69877a72022-08-10 09:20:01 +09001965 create_info.pRasterizationState,
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001966 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, true,
1967 "VUID-VkGraphicsPipelineCreateInfo-pRasterizationState-06601",
1968 "VUID-VkPipelineRasterizationStateCreateInfo-sType-sType");
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001969 }
1970
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001971 // TODO probably should check dynamic state from graphics libraries, at least when creating an "executable pipeline"
1972 if (create_info.pDynamicState != nullptr) {
1973 const auto &dynamic_state_info = *create_info.pDynamicState;
Petr Kraus299ba622017-11-24 03:09:03 +01001974 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1975 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001976 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1977 if (has_dynamic_viewport == true) {
1978 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1979 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001980 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001981 i);
1982 }
1983 has_dynamic_viewport = true;
1984 }
1985 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1986 if (has_dynamic_scissor == true) {
1987 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1988 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001989 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001990 i);
1991 }
1992 has_dynamic_scissor = true;
1993 }
1994 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1995 if (has_dynamic_line_width == true) {
1996 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1997 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001998 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001999 i);
2000 }
2001 has_dynamic_line_width = true;
2002 }
2003 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
2004 if (has_dynamic_depth_bias == true) {
2005 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2006 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002007 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002008 i);
2009 }
2010 has_dynamic_depth_bias = true;
2011 }
2012 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
2013 if (has_dynamic_blend_constant == true) {
2014 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2015 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002016 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002017 i);
2018 }
2019 has_dynamic_blend_constant = true;
2020 }
2021 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
2022 if (has_dynamic_depth_bounds == true) {
2023 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2024 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002025 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002026 i);
2027 }
2028 has_dynamic_depth_bounds = true;
2029 }
2030 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
2031 if (has_dynamic_stencil_compare == true) {
2032 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2033 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002034 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002035 i);
2036 }
2037 has_dynamic_stencil_compare = true;
2038 }
2039 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
2040 if (has_dynamic_stencil_write == true) {
2041 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2042 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002043 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002044 i);
2045 }
2046 has_dynamic_stencil_write = true;
2047 }
2048 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
2049 if (has_dynamic_stencil_reference == true) {
2050 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2051 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002052 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002053 i);
2054 }
2055 has_dynamic_stencil_reference = true;
2056 }
2057 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
2058 if (has_dynamic_viewport_w_scaling_nv == true) {
2059 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2060 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002061 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002062 i);
2063 }
2064 has_dynamic_viewport_w_scaling_nv = true;
2065 }
2066 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
2067 if (has_dynamic_discard_rectangle_ext == true) {
2068 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2069 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002070 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002071 i);
2072 }
2073 has_dynamic_discard_rectangle_ext = true;
2074 }
2075 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
2076 if (has_dynamic_sample_locations_ext == true) {
2077 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2078 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002079 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002080 i);
2081 }
2082 has_dynamic_sample_locations_ext = true;
2083 }
2084 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
2085 if (has_dynamic_exclusive_scissor_nv == true) {
2086 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2087 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002088 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002089 i);
2090 }
2091 has_dynamic_exclusive_scissor_nv = true;
2092 }
2093 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
2094 if (has_dynamic_shading_rate_palette_nv == true) {
2095 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2096 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002097 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002098 i);
2099 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06002100 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07002101 }
2102 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
2103 if (has_dynamic_viewport_course_sample_order_nv == true) {
2104 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2105 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002106 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002107 i);
2108 }
2109 has_dynamic_viewport_course_sample_order_nv = true;
2110 }
2111 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
2112 if (has_dynamic_line_stipple == true) {
2113 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2114 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002115 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002116 i);
2117 }
2118 has_dynamic_line_stipple = true;
2119 }
Piers Daniell39842ee2020-07-10 16:42:33 -06002120 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
2121 if (has_dynamic_cull_mode) {
2122 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2123 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002124 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002125 i);
2126 }
2127 has_dynamic_cull_mode = true;
2128 }
2129 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
2130 if (has_dynamic_front_face) {
2131 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2132 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002133 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002134 i);
2135 }
2136 has_dynamic_front_face = true;
2137 }
2138 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
2139 if (has_dynamic_primitive_topology) {
2140 skip |= LogError(
2141 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2142 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002143 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002144 i);
2145 }
2146 has_dynamic_primitive_topology = true;
2147 }
2148 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
2149 if (has_dynamic_viewport_with_count) {
2150 skip |= LogError(
2151 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2152 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002153 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002154 i);
2155 }
2156 has_dynamic_viewport_with_count = true;
2157 }
2158 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
2159 if (has_dynamic_scissor_with_count) {
2160 skip |= LogError(
2161 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2162 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002163 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002164 i);
2165 }
2166 has_dynamic_scissor_with_count = true;
2167 }
2168 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
2169 if (has_dynamic_vertex_input_binding_stride) {
2170 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2171 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
2172 "listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002173 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002174 i);
2175 }
2176 has_dynamic_vertex_input_binding_stride = true;
2177 }
2178 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
2179 if (has_dynamic_depth_test_enable) {
2180 skip |= LogError(
2181 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2182 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002183 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002184 i);
2185 }
2186 has_dynamic_depth_test_enable = true;
2187 }
2188 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
2189 if (has_dynamic_depth_write_enable) {
2190 skip |= LogError(
2191 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2192 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002193 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002194 i);
2195 }
2196 has_dynamic_depth_write_enable = true;
2197 }
2198 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
2199 if (has_dynamic_depth_compare_op) {
2200 skip |=
2201 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2202 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002203 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002204 i);
2205 }
2206 has_dynamic_depth_compare_op = true;
2207 }
2208 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
2209 if (has_dynamic_depth_bounds_test_enable) {
2210 skip |= LogError(
2211 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2212 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002213 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002214 i);
2215 }
2216 has_dynamic_depth_bounds_test_enable = true;
2217 }
2218 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
2219 if (has_dynamic_stencil_test_enable) {
2220 skip |= LogError(
2221 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2222 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002223 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002224 i);
2225 }
2226 has_dynamic_stencil_test_enable = true;
2227 }
2228 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
2229 if (has_dynamic_stencil_op) {
2230 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2231 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002232 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002233 i);
2234 }
2235 has_dynamic_stencil_op = true;
2236 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002237 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
2238 // Not allowed for graphics pipelines
2239 skip |= LogError(
2240 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
2241 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002242 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates[%" PRIu32
2243 "] but not allowed in graphic pipelines.",
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002244 i, state_index);
2245 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002246 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
2247 if (has_patch_control_points) {
2248 skip |= LogError(
2249 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2250 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002251 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002252 i);
2253 }
2254 has_patch_control_points = true;
2255 }
2256 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
2257 if (has_rasterizer_discard_enable) {
2258 skip |= LogError(
2259 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2260 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002261 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002262 i);
2263 }
2264 has_rasterizer_discard_enable = true;
2265 }
2266 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
2267 if (has_depth_bias_enable) {
2268 skip |= LogError(
2269 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2270 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002271 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002272 i);
2273 }
2274 has_depth_bias_enable = true;
2275 }
2276 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
2277 if (has_logic_op) {
2278 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2279 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002280 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002281 i);
2282 }
2283 has_logic_op = true;
2284 }
2285 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
2286 if (has_primitive_restart_enable) {
2287 skip |= LogError(
2288 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2289 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002290 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002291 i);
2292 }
2293 has_primitive_restart_enable = true;
2294 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06002295 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
2296 if (has_dynamic_vertex_input) {
2297 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002298 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
2299 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
2300 i);
Piers Daniellcb6d8032021-04-19 18:51:26 -06002301 }
2302 has_dynamic_vertex_input = true;
2303 }
Petr Kraus299ba622017-11-24 03:09:03 +01002304 }
2305 }
2306
sfricke-samsung3b944422021-01-23 02:15:19 -08002307 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
2308 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
2309 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002310 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%" PRIu32
2311 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002312 i);
2313 }
2314
2315 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
2316 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
2317 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002318 "both listed in pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002319 i);
2320 }
2321
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002322 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(create_info.pNext);
2323 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != create_info.stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06002324 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pipelineStageCreationFeedbackCount-06594",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002325 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
2326 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
2327 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002328 i, feedback_struct->pipelineStageCreationFeedbackCount, create_info.stageCount);
Peter Chen85366392019-05-14 15:20:11 -04002329 }
2330
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002331 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002332
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002333 // Collect active stages and other information
2334 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002335 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002336 bool has_eval = false;
2337 bool has_control = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002338 if (create_info.pStages != nullptr) {
2339 for (uint32_t stage_index = 0; stage_index < create_info.stageCount; ++stage_index) {
2340 active_shaders |= create_info.pStages[stage_index].stage;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002341
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002342 if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002343 has_control = true;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002344 } else if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002345 has_eval = true;
2346 }
2347
Tony-LunarGd29cc032022-05-13 14:38:27 -06002348 skip |= validate_required_pointer(
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002349 "vkCreateGraphicsPipelines",
Tony-LunarGd29cc032022-05-13 14:38:27 -06002350 ParameterName("pCreateInfos[%i].stage[%i].pName", ParameterName::IndexVector{i, stage_index}),
2351 create_info.pStages[stage_index].pName, "VUID-VkPipelineShaderStageCreateInfo-pName-parameter");
2352
2353 if (create_info.pStages[stage_index].pName) {
2354 skip |= validate_string(
2355 "vkCreateGraphicsPipelines",
2356 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2357 kVUID_Stateless_InvalidShaderStagesArray, create_info.pStages[stage_index].pName);
2358 }
ziga-lunargc6341372021-07-28 12:57:42 +02002359
2360 std::stringstream msg;
2361 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2362 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002363 &create_info.pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002364 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002365 }
2366
2367 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002368 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (create_info.pTessellationState != nullptr)) {
2369 skip |=
2370 validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2371 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2372 create_info.pTessellationState, VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO,
2373 false, kVUIDUndefined, "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002374
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002375 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002376 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2377
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002378 skip |= validate_struct_pnext(
2379 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002380 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002381 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2382 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2383 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2384 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002385
2386 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002387 create_info.pTessellationState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002388 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2389 }
2390
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002391 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pInputAssemblyState != nullptr)) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002392 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2393 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002394 create_info.pInputAssemblyState,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002395 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2396 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2397
2398 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002399 create_info.pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002400 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002401
2402 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002403 create_info.pInputAssemblyState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002404 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2405
2406 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2407 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002408 create_info.pInputAssemblyState->topology,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002409 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2410
2411 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002412 create_info.pInputAssemblyState->primitiveRestartEnable);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002413 }
2414
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002415 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pVertexInputState != nullptr)) {
2416 auto const &vertex_input_state = create_info.pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002417
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002418 if (create_info.pVertexInputState->flags != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002419 skip |=
2420 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2421 "vkCreateGraphicsPipelines: pararameter "
2422 "pCreateInfos[%" PRIu32 "].pVertexInputState->flags (%" PRIu32 ") is reserved and must be zero.",
2423 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002424 }
2425
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002426 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002427 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002428 skip |=
2429 validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2430 "VkPipelineVertexInputDivisorStateCreateInfoEXT", create_info.pVertexInputState->pNext, 1,
2431 allowed_structs_vk_pipeline_vertex_input_state_create_info, GeneratedVulkanHeaderVersion,
2432 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
2433 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002434 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2435 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002436 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002437 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2438 skip |=
2439 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2440 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002441 create_info.pVertexInputState->vertexBindingDescriptionCount,
2442 &create_info.pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002443 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2444
2445 skip |= validate_array(
2446 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2447 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2448 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2449 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2450
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002451 if (create_info.pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002452 for (uint32_t vertex_binding_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002453 vertex_binding_description_index < create_info.pVertexInputState->vertexBindingDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002454 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002455 skip |= validate_ranged_enum(
2456 "vkCreateGraphicsPipelines",
2457 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2458 AllVkVertexInputRateEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002459 create_info.pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index].inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002460 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2461 }
2462 }
2463
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002464 if (create_info.pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002465 for (uint32_t vertex_attribute_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002466 vertex_attribute_description_index < create_info.pVertexInputState->vertexAttributeDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002467 ++vertex_attribute_description_index) {
sfricke-samsung2e827212021-09-28 07:52:08 -07002468 const VkFormat format =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002469 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002470 skip |= validate_ranged_enum(
2471 "vkCreateGraphicsPipelines",
2472 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2473 AllVkFormatEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002474 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002475 "VUID-VkVertexInputAttributeDescription-format-parameter");
sfricke-samsung2e827212021-09-28 07:52:08 -07002476 if (FormatIsDepthOrStencil(format)) {
2477 // Should never hopefully get here, but there are known driver advertising the wrong feature flags
2478 // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849
2479 skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat,
2480 "vkCreateGraphicsPipelines: "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002481 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2482 "].format is a "
sfricke-samsung2e827212021-09-28 07:52:08 -07002483 "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for "
2484 "alignment, replace with a color format.",
2485 i, vertex_attribute_description_index, string_VkFormat(format));
2486 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002487 }
2488 }
2489
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002490 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002491 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2492 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002493 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexBindingDescriptionCount (%" PRIu32
2494 ") is "
2495 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002496 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002497 }
2498
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002499 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002500 skip |=
2501 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2502 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002503 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptionCount (%" PRIu32
2504 ") is "
2505 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002506 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002507 }
2508
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002509 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002510 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2511 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002512 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2513 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002514 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2515 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002516 "pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription[%" PRIu32
2517 "].binding "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002518 "(%" PRIu32 ") is not distinct.",
2519 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002520 }
2521 vertex_bindings.insert(vertex_bind_desc.binding);
2522
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002523 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002524 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2525 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002526 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2527 "].binding (%" PRIu32
2528 ") is "
2529 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002530 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002531 }
2532
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002533 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002534 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2535 "vkCreateGraphicsPipelines: parameter "
2536 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2537 "].stride (%" PRIu32
2538 ") is greater "
2539 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%" PRIu32 ").",
2540 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002541 }
2542 }
2543
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002544 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002545 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2546 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002547 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2548 if (location_it != attribute_locations.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002549 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
2550 "vkCreateGraphicsPipelines: parameter "
2551 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2552 "].location (%" PRIu32 ") is not distinct.",
2553 i, d, vertex_attrib_desc.location);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002554 }
2555 attribute_locations.insert(vertex_attrib_desc.location);
2556
2557 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2558 if (binding_it == vertex_bindings.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002559 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
2560 "vkCreateGraphicsPipelines: parameter "
2561 " pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2562 "].binding (%" PRIu32
2563 ") does not exist "
2564 "in any pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription.",
2565 i, d, vertex_attrib_desc.binding, i);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002566 }
2567
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002568 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002569 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2570 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002571 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2572 "].location (%" PRIu32
2573 ") is "
2574 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002575 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002576 }
2577
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002578 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002579 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2580 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002581 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2582 "].binding (%" PRIu32
2583 ") is "
2584 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002585 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002586 }
2587
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002588 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002589 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2590 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002591 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2592 "].offset (%" PRIu32
2593 ") is "
2594 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002595 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002596 }
2597 }
2598 }
2599
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002600 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2601 if (has_control && has_eval) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002602 if (create_info.pTessellationState == nullptr) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002603 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002604 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2605 "].pStages includes a tessellation control "
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002606 "shader stage and a tessellation evaluation shader stage, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002607 "pCreateInfos[%" PRIu32 "].pTessellationState must not be NULL.",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002608 i, i);
2609 } else {
2610 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2611 skip |= validate_struct_pnext(
2612 "vkCreateGraphicsPipelines",
2613 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002614 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext, 1,
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002615 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2616 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002617
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002618 skip |= validate_reserved_flags(
2619 "vkCreateGraphicsPipelines",
2620 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002621 create_info.pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002622
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002623 if (create_info.pTessellationState->patchControlPoints == 0 ||
2624 create_info.pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2625 skip |=
2626 LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2627 "vkCreateGraphicsPipelines: invalid parameter "
2628 "pCreateInfos[%" PRIu32 "].pTessellationState->patchControlPoints value %" PRIu32
2629 ". patchControlPoints "
2630 "should be >0 and <=%" PRIu32 ".",
2631 i, create_info.pTessellationState->patchControlPoints, device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002632 }
2633 }
2634 }
2635
2636 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002637 if ((create_info.pRasterizationState != nullptr) &&
2638 (create_info.pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2639 if (create_info.pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002640 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2641 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2642 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2643 "].pViewportState (=NULL) is not a valid pointer.",
2644 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002645 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002646 const auto &viewport_state = *create_info.pViewportState;
Petr Krausa6103552017-11-16 21:21:58 +01002647
2648 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002649 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2650 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2651 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2652 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002653 }
2654
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002655 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002656 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002657 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2658 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002659 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2660 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002661 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002662 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002663 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002664 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002665 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002666 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002667 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002668 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV, VkPipelineViewportDepthClipControlCreateInfoEXT",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002669 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002670 allowed_structs_vk_pipeline_viewport_state_create_info, 200,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002671 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002672 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002673
2674 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002675 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002676 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002677 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002678
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002679 auto exclusive_scissor_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002680 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002681 auto shading_rate_image_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002682 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002683 auto coarse_sample_order_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002684 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(viewport_state.pNext);
2685 const auto vp_swizzle_struct = LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(viewport_state.pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002686 const auto vp_w_scaling_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002687 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(viewport_state.pNext);
2688 const auto depth_clip_control_struct =
2689 LvlFindInChain<VkPipelineViewportDepthClipControlCreateInfoEXT>(viewport_state.pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002690
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002691 if (!physical_device_features.multiViewport) {
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06002692 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount > 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002693 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2694 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2695 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2696 ") is not 1.",
2697 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002698 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002699
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06002700 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount > 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002701 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2702 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2703 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2704 ") is not 1.",
2705 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002706 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002707
Dave Houlton142c4cb2018-10-17 15:04:41 -06002708 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2709 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002710 skip |= LogError(
2711 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2712 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2713 "disabled, but pCreateInfos[%" PRIu32
2714 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2715 ") is not 1.",
2716 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002717 }
2718
Jeff Bolz9af91c52018-09-01 21:53:57 -05002719 if (shading_rate_image_struct &&
2720 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002721 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2722 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2723 "disabled, but pCreateInfos[%" PRIu32
2724 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2725 ") is neither 0 nor 1.",
2726 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002727 }
2728
Petr Krausa6103552017-11-16 21:21:58 +01002729 } else { // multiViewport enabled
2730 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002731 if (!has_dynamic_viewport_with_count) {
2732 skip |= LogError(
2733 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2734 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2735 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002736 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002737 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2738 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2739 "].pViewportState->viewportCount (=%" PRIu32
2740 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2741 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002742 } else if (has_dynamic_viewport_with_count) {
2743 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2744 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2745 "].pViewportState->viewportCount (=%" PRIu32
2746 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2747 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002748 }
Petr Krausa6103552017-11-16 21:21:58 +01002749
2750 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002751 if (!has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002752 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2753 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2754 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength";
Piers Daniell39842ee2020-07-10 16:42:33 -06002755 skip |= LogError(
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002756 device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002757 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2758 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002759 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002760 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2761 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2762 "].pViewportState->scissorCount (=%" PRIu32
2763 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2764 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002765 } else if (has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002766 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2767 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2768 : "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380";
2769 skip |= LogError(device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002770 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2771 "].pViewportState->scissorCount (=%" PRIu32
2772 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2773 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002774 }
2775 }
2776
ziga-lunarg845883b2021-07-14 15:05:00 +02002777 if (!has_dynamic_scissor && viewport_state.pScissors) {
2778 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2779 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002780
2781 if (scissor.offset.x < 0) {
2782 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2783 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2784 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2785 scissor.offset.x, i, scissor_i);
2786 }
2787
2788 if (scissor.offset.y < 0) {
2789 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2790 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2791 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2792 scissor.offset.y, i, scissor_i);
2793 }
2794
ziga-lunarg845883b2021-07-14 15:05:00 +02002795 const int64_t x_sum =
2796 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2797 if (x_sum > std::numeric_limits<int32_t>::max()) {
2798 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2799 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2800 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2801 "] will overflow int32_t.",
2802 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2803 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002804
ziga-lunarg845883b2021-07-14 15:05:00 +02002805 const int64_t y_sum =
2806 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2807 if (y_sum > std::numeric_limits<int32_t>::max()) {
2808 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2809 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2810 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2811 "] will overflow int32_t.",
2812 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2813 }
2814 }
2815 }
2816
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002817 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002818 skip |=
2819 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2820 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2821 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2822 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002823 }
2824
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002825 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002826 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2827 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2828 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2829 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2830 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002831 }
2832
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002833 if (viewport_state.scissorCount != viewport_state.viewportCount) {
2834 if (!IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) ||
2835 (!has_dynamic_viewport_with_count && !has_dynamic_scissor_with_count)) {
2836 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2837 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04134"
2838 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220";
2839 skip |= LogError(
2840 device, vuid,
2841 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2842 ") is not identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2843 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
2844 }
Petr Krausa6103552017-11-16 21:21:58 +01002845 }
2846
Dave Houlton142c4cb2018-10-17 15:04:41 -06002847 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002848 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002849 skip |=
2850 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2851 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2852 ") must be zero or identical to pCreateInfos[%" PRIu32
2853 "].pViewportState->viewportCount (=%" PRIu32 ").",
2854 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002855 }
2856
Dave Houlton142c4cb2018-10-17 15:04:41 -06002857 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002858 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002859 skip |= LogError(
2860 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002861 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2862 "] "
2863 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2864 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2865 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002866 }
2867
Petr Krausa6103552017-11-16 21:21:58 +01002868 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002869 skip |= LogError(
2870 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002871 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2872 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002873 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2874 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002875 }
2876
2877 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002878 skip |= LogError(
2879 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002880 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2881 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002882 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2883 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002884 }
2885
Jeff Bolz3e71f782018-08-29 23:15:45 -05002886 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002887 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2888 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2889 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002890 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002891 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2892 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2893 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2894 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002895 }
2896
Jeff Bolz9af91c52018-09-01 21:53:57 -05002897 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002898 shading_rate_image_struct->viewportCount > 0 &&
2899 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002900 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002901 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002902 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002903 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2904 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002905 i, i);
2906 }
2907
Chris Mayer328d8212018-12-11 14:16:18 +01002908 if (vp_swizzle_struct) {
2909 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002910 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2911 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2912 " does "
2913 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2914 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002915 }
2916 }
2917
Petr Krausb3fcdb42018-01-09 22:09:09 +01002918 // validate the VkViewports
2919 if (!has_dynamic_viewport && viewport_state.pViewports) {
2920 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2921 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002922 const char *fn_name = "vkCreateGraphicsPipelines";
2923 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2924 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2925 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002926 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002927 }
2928 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002929
sfricke-samsung45996a42021-09-16 13:45:27 -07002930 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002931 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2932 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2933 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2934 "VK_NV_clip_space_w_scaling extension is not enabled.",
2935 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002936 }
2937
sfricke-samsung45996a42021-09-16 13:45:27 -07002938 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002939 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2940 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2941 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2942 "VK_EXT_discard_rectangles extension is not enabled.",
2943 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002944 }
2945
sfricke-samsung45996a42021-09-16 13:45:27 -07002946 if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002947 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2948 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2949 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2950 "VK_EXT_sample_locations extension is not enabled.",
2951 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002952 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002953
sfricke-samsung45996a42021-09-16 13:45:27 -07002954 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002955 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2956 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2957 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2958 "VK_NV_scissor_exclusive extension is not enabled.",
2959 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002960 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002961
2962 if (coarse_sample_order_struct &&
2963 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2964 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002965 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2966 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2967 "] "
2968 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2969 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2970 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002971 }
2972
2973 if (coarse_sample_order_struct) {
2974 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002975 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002976 }
2977 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002978
2979 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2980 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002981 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2982 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2983 "] "
2984 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2985 ") "
2986 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2987 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002988 }
2989 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002990 skip |= LogError(
2991 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002992 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2993 "] "
2994 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2995 i);
2996 }
2997 }
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002998
2999 if (depth_clip_control_struct) {
3000 const auto *depth_clip_control_features =
3001 LvlFindInChain<VkPhysicalDeviceDepthClipControlFeaturesEXT>(device_createinfo_pnext);
3002 const bool enabled_depth_clip_control =
3003 depth_clip_control_features && depth_clip_control_features->depthClipControl;
3004 if (depth_clip_control_struct->negativeOneToOne && !enabled_depth_clip_control) {
3005 skip |= LogError(device, "VUID-VkPipelineViewportDepthClipControlCreateInfoEXT-negativeOneToOne-06470",
3006 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3007 "].pViewportState has negativeOneToOne set to VK_TRUE in the pNext chain, but the "
3008 "depthClipControl feature is not enabled. ",
3009 i);
3010 }
3011 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003012 }
3013
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003014 const bool is_frag_out_graphics_lib =
3015 graphics_lib_info &&
3016 ((graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT) != 0);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003017 if (is_frag_out_graphics_lib && (create_info.pMultisampleState == nullptr)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003018 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003019 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
3020 "].pRasterizationState->rasterizerDiscardEnable "
3021 "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003022 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003023 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07003024 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06003025 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07003026 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
3027 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07003028 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07003029 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07003030 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003031
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003032 // It is possible for pCreateInfos[i].pMultisampleState to be null when creating a graphics library
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003033 if (create_info.pMultisampleState) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003034 skip |= validate_struct_pnext(
3035 "vkCreateGraphicsPipelines",
3036 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003037 valid_struct_names, create_info.pMultisampleState->pNext, 4, valid_next_stypes,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003038 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
3039 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003040
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003041 skip |= validate_reserved_flags(
3042 "vkCreateGraphicsPipelines",
3043 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003044 create_info.pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003045
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003046 skip |= validate_bool32(
3047 "vkCreateGraphicsPipelines",
3048 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003049 create_info.pMultisampleState->sampleShadingEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003050
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003051 skip |= validate_array(
3052 "vkCreateGraphicsPipelines",
3053 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
3054 ParameterName::IndexVector{i}),
3055 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003056 create_info.pMultisampleState->rasterizationSamples, &create_info.pMultisampleState->pSampleMask, true,
3057 false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06003058
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003059 skip |= validate_flags("vkCreateGraphicsPipelines",
3060 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
3061 ParameterName::IndexVector{i}),
3062 "VkSampleCountFlagBits", AllVkSampleCountFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003063 create_info.pMultisampleState->rasterizationSamples, kRequiredSingleBit,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003064 "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003065
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003066 skip |= validate_bool32("vkCreateGraphicsPipelines",
3067 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable",
3068 ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003069 create_info.pMultisampleState->alphaToCoverageEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003070
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003071 skip |= validate_bool32(
3072 "vkCreateGraphicsPipelines",
3073 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003074 create_info.pMultisampleState->alphaToOneEnable);
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003075
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003076 if (create_info.pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003077 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
3078 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3079 "].pMultisampleState->sType must be "
3080 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003081 i);
John Zulauf7acac592017-11-06 11:15:53 -07003082 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003083 if (create_info.pMultisampleState->sampleShadingEnable == VK_TRUE) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003084 if (!physical_device_features.sampleRateShading) {
3085 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
3086 "vkCreateGraphicsPipelines(): parameter "
3087 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.",
3088 i);
3089 }
3090 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
3091 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003092 if (!in_inclusive_range(create_info.pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003093 skip |= LogError(device,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003094
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003095 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
3096 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32
3097 "].pMultisampleState->minSampleShading.",
3098 i);
3099 }
John Zulauf7acac592017-11-06 11:15:53 -07003100 }
3101 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003102
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003103 const auto *line_state =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003104 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(create_info.pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003105
3106 if (line_state) {
3107 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
3108 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003109 if (create_info.pMultisampleState->alphaToCoverageEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003110 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003111 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3112 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003113 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003114 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003115 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003116 if (create_info.pMultisampleState->alphaToOneEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003117 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003118 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3119 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003120 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToOneEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003121 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003122 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003123 if (create_info.pMultisampleState->sampleShadingEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003124 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003125 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3126 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003127 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003128 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003129 }
3130 }
3131 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
3132 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
3133 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003134 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003135 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32
3136 " must be in the "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003137 "range [1,256].",
3138 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003139 }
3140 }
3141 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003142 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003143 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
3144 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003145 skip |=
3146 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003147 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3148 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003149 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
3150 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003151 }
3152 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
3153 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003154 skip |=
3155 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003156 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3157 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003158 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
3159 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003160 }
3161 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
3162 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003163 skip |=
3164 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003165 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3166 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003167 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
3168 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003169 }
3170 if (line_state->stippledLineEnable) {
3171 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
3172 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003173 skip |=
3174 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003175 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3176 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003177 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
3178 "stippledRectangularLines feature.",
3179 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003180 }
3181 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
3182 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003183 skip |=
3184 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003185 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3186 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003187 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
3188 "stippledBresenhamLines feature.",
3189 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003190 }
3191 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
3192 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003193 skip |=
3194 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003195 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3196 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003197 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
3198 "stippledSmoothLines feature.",
3199 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003200 }
3201 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
Malcolm Bechardfc509002021-11-17 21:57:28 -05003202 (!line_features || !line_features->stippledRectangularLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003203 skip |=
3204 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003205 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3206 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003207 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
3208 "stippledRectangularLines and strictLines features.",
3209 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003210 }
3211 }
3212 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003213 }
3214
Petr Krause91f7a12017-12-14 20:57:36 +01003215 bool uses_color_attachment = false;
3216 bool uses_depthstencil_attachment = false;
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003217 VkSubpassDescriptionFlags subpass_flags = 0;
Petr Krause91f7a12017-12-14 20:57:36 +01003218 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003219 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003220 const auto subpasses_uses_it = renderpasses_states.find(create_info.renderPass);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003221 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01003222 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003223 if (subpasses_uses.subpasses_using_color_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003224 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003225 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003226 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003227 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003228 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003229 subpass_flags = subpasses_uses.subpasses_flags[create_info.subpass];
sjfricke69877a72022-08-10 09:20:01 +09003230
3231 color_attachment_count = subpasses_uses.color_attachment_count;
Petr Krause91f7a12017-12-14 20:57:36 +01003232 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003233 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01003234 }
3235
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003236 if (create_info.pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003237 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003238 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003239 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003240 create_info.pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003241 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003242
Mike Schuchardt00e81452021-11-29 11:11:20 -08003243 skip |=
3244 validate_flags("vkCreateGraphicsPipelines",
3245 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
3246 "VkPipelineDepthStencilStateCreateFlagBits", AllVkPipelineDepthStencilStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003247 create_info.pDepthStencilState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003248 "VUID-VkPipelineDepthStencilStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003249
3250 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003251 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003252 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003253 create_info.pDepthStencilState->depthTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003254
3255 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003256 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003257 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003258 create_info.pDepthStencilState->depthWriteEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003259
3260 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003261 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003262 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003263 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003264 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003265
3266 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003267 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003268 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003269 create_info.pDepthStencilState->depthBoundsTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003270
3271 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003272 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003273 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003274 create_info.pDepthStencilState->stencilTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003275
3276 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003277 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003278 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003279 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003280 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003281
3282 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003283 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003284 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003285 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003286 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003287
3288 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003289 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003290 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003291 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003292 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003293
3294 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003295 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003296 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003297 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003298 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003299
3300 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003301 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003302 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003303 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003304 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003305
3306 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003307 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003308 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003309 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003310 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003311
3312 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003313 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003314 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003315 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003316 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003317
3318 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003319 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003320 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003321 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003322 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003323
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003324 if (create_info.pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003325 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003326 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3327 "].pDepthStencilState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003328 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
3329 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003330 }
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003331
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003332 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003333 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) != 0) {
3334 const auto *rasterization_order_attachment_access_feature =
3335 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3336 const bool rasterization_order_depth_attachment_access_feature_enabled =
3337 rasterization_order_attachment_access_feature &&
3338 rasterization_order_attachment_access_feature->rasterizationOrderDepthAttachmentAccess == VK_TRUE;
3339 if (!rasterization_order_depth_attachment_access_feature_enabled) {
3340 skip |= LogError(
3341 device, "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderDepthAttachmentAccess-06463",
3342 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3343 "rasterizationOrderDepthAttachmentAccess == VK_FALSE, but "
3344 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003345 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003346 }
3347
3348 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) == 0) {
3349 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003350 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06485",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003351 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3352 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003353 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003354 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3355 }
3356 }
3357
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003358 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003359 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) != 0) {
3360 const auto *rasterization_order_attachment_access_feature =
3361 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3362 const bool rasterization_order_stencil_attachment_access_feature_enabled =
3363 rasterization_order_attachment_access_feature &&
3364 rasterization_order_attachment_access_feature->rasterizationOrderStencilAttachmentAccess == VK_TRUE;
3365 if (!rasterization_order_stencil_attachment_access_feature_enabled) {
3366 skip |= LogError(
3367 device,
3368 "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderStencilAttachmentAccess-06464",
3369 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3370 "rasterizationOrderStencilAttachmentAccess == VK_FALSE, but "
3371 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003372 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003373 }
3374
3375 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) == 0) {
3376 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003377 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06486",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003378 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3379 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003380 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003381 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3382 }
3383 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003384 }
3385
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003386 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02003387 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
3388 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003389
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003390 if (create_info.pColorBlendState != nullptr && uses_color_attachment) {
3391 skip |=
3392 validate_struct_type("vkCreateGraphicsPipelines",
3393 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
3394 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3395 create_info.pColorBlendState, VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
3396 false, kVUIDUndefined, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06003397
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003398 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003399 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003400 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003401 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT",
3402 create_info.pColorBlendState->pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003403 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003404 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
3405 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003406
Mike Schuchardt00e81452021-11-29 11:11:20 -08003407 skip |= validate_flags("vkCreateGraphicsPipelines",
3408 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
3409 "VkPipelineColorBlendStateCreateFlagBits", AllVkPipelineColorBlendStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003410 create_info.pColorBlendState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003411 "VUID-VkPipelineColorBlendStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003412
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003413 if ((create_info.pColorBlendState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003414 VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM) != 0) {
3415 const auto *rasterization_order_attachment_access_feature =
3416 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3417 const bool rasterization_order_color_attachment_access_feature_enabled =
3418 rasterization_order_attachment_access_feature &&
3419 rasterization_order_attachment_access_feature->rasterizationOrderColorAttachmentAccess == VK_TRUE;
3420
3421 if (!rasterization_order_color_attachment_access_feature_enabled) {
3422 skip |= LogError(
3423 device, "VUID-VkPipelineColorBlendStateCreateInfo-rasterizationOrderColorAttachmentAccess-06465",
3424 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3425 "rasterizationColorAttachmentAccess == VK_FALSE, but "
3426 "VkPipelineColorBlendStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003427 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003428 }
3429
3430 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM) == 0) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003431 skip |=
3432 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-06484",
3433 "VkPipelineColorBlendStateCreateInfo::flags == %s but "
3434 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3435 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str(),
3436 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003437 }
3438 }
3439
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003440 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003441 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003442 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003443 create_info.pColorBlendState->logicOpEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003444
3445 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003446 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003447 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
3448 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003449 create_info.pColorBlendState->attachmentCount, &create_info.pColorBlendState->pAttachments, false, true,
3450 kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003451
sjfricke69877a72022-08-10 09:20:01 +09003452 if (create_info.pColorBlendState->pAttachments != nullptr) {
3453 const VkBlendOp first_color_blend_op = create_info.pColorBlendState->pAttachments[0].colorBlendOp;
3454 const VkBlendOp first_alpha_blend_op = create_info.pColorBlendState->pAttachments[0].alphaBlendOp;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003455 for (uint32_t attachment_index = 0; attachment_index < create_info.pColorBlendState->attachmentCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003456 ++attachment_index) {
sjfricke69877a72022-08-10 09:20:01 +09003457 const VkPipelineColorBlendAttachmentState attachment_state =
3458 create_info.pColorBlendState->pAttachments[attachment_index];
3459
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003460 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003461 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003462 ParameterName::IndexVector{i, attachment_index}),
sjfricke69877a72022-08-10 09:20:01 +09003463 attachment_state.blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003464
3465 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003466 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003467 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003468 ParameterName::IndexVector{i, attachment_index}),
sjfricke69877a72022-08-10 09:20:01 +09003469 "VkBlendFactor", AllVkBlendFactorEnums, attachment_state.srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003470 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003471
3472 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003473 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003474 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003475 ParameterName::IndexVector{i, attachment_index}),
sjfricke69877a72022-08-10 09:20:01 +09003476 "VkBlendFactor", AllVkBlendFactorEnums, attachment_state.dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003477 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003478
3479 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003480 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003481 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003482 ParameterName::IndexVector{i, attachment_index}),
sjfricke69877a72022-08-10 09:20:01 +09003483 "VkBlendOp", AllVkBlendOpEnums, attachment_state.colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003484 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003485
3486 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003487 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003488 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003489 ParameterName::IndexVector{i, attachment_index}),
sjfricke69877a72022-08-10 09:20:01 +09003490 "VkBlendFactor", AllVkBlendFactorEnums, attachment_state.srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003491 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003492
3493 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003494 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003495 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003496 ParameterName::IndexVector{i, attachment_index}),
sjfricke69877a72022-08-10 09:20:01 +09003497 "VkBlendFactor", AllVkBlendFactorEnums, attachment_state.dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003498 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003499
3500 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003501 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003502 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003503 ParameterName::IndexVector{i, attachment_index}),
sjfricke69877a72022-08-10 09:20:01 +09003504 "VkBlendOp", AllVkBlendOpEnums, attachment_state.alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003505 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003506
sjfricke69877a72022-08-10 09:20:01 +09003507 skip |= validate_flags(
3508 "vkCreateGraphicsPipelines",
3509 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
3510 ParameterName::IndexVector{i, attachment_index}),
3511 "VkColorComponentFlagBits", AllVkColorComponentFlagBits, attachment_state.colorWriteMask,
3512 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003513
sjfricke69877a72022-08-10 09:20:01 +09003514 // if blendEnabled is false, these values are ignored
3515 if (attachment_state.blendEnable) {
3516 bool advance_blend = false;
3517 if (IsAdvanceBlendOperation(attachment_state.colorBlendOp)) {
3518 advance_blend = true;
3519 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3520 // This VUID checks if a subset of advance blend ops are allowed
3521 switch (attachment_state.colorBlendOp) {
3522 case VK_BLEND_OP_ZERO_EXT:
3523 case VK_BLEND_OP_SRC_EXT:
3524 case VK_BLEND_OP_DST_EXT:
3525 case VK_BLEND_OP_SRC_OVER_EXT:
3526 case VK_BLEND_OP_DST_OVER_EXT:
3527 case VK_BLEND_OP_SRC_IN_EXT:
3528 case VK_BLEND_OP_DST_IN_EXT:
3529 case VK_BLEND_OP_SRC_OUT_EXT:
3530 case VK_BLEND_OP_DST_OUT_EXT:
3531 case VK_BLEND_OP_SRC_ATOP_EXT:
3532 case VK_BLEND_OP_DST_ATOP_EXT:
3533 case VK_BLEND_OP_XOR_EXT:
3534 case VK_BLEND_OP_INVERT_EXT:
3535 case VK_BLEND_OP_INVERT_RGB_EXT:
3536 case VK_BLEND_OP_LINEARDODGE_EXT:
3537 case VK_BLEND_OP_LINEARBURN_EXT:
3538 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3539 case VK_BLEND_OP_LINEARLIGHT_EXT:
3540 case VK_BLEND_OP_PINLIGHT_EXT:
3541 case VK_BLEND_OP_HARDMIX_EXT:
3542 case VK_BLEND_OP_PLUS_EXT:
3543 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3544 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3545 case VK_BLEND_OP_PLUS_DARKER_EXT:
3546 case VK_BLEND_OP_MINUS_EXT:
3547 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3548 case VK_BLEND_OP_CONTRAST_EXT:
3549 case VK_BLEND_OP_INVERT_OVG_EXT:
3550 case VK_BLEND_OP_RED_EXT:
3551 case VK_BLEND_OP_GREEN_EXT:
3552 case VK_BLEND_OP_BLUE_EXT: {
3553 skip |= LogError(
3554 device,
3555 "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3556 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3557 "].pColorBlendState->pAttachments[%" PRIu32
3558 "].colorBlendOp (%s) is not valid when "
3559 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::"
3560 "advancedBlendAllOperations is "
3561 "VK_FALSE",
3562 i, attachment_index, string_VkBlendOp(attachment_state.colorBlendOp));
3563 break;
3564 }
3565 default:
3566 break;
3567 }
3568 }
3569
3570 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendIndependentBlend ==
3571 VK_FALSE &&
3572 attachment_state.colorBlendOp != first_color_blend_op) {
3573 skip |= LogError(
3574 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendIndependentBlend-01407",
3575 "vkCreateGraphicsPipelines: advancedBlendIndependentBlend is set to VK_FALSE, but "
3576 "pCreateInfos[%" PRIu32 "].pColorBlendState->pAttachments[%" PRIu32
3577 "].colorBlendOp (%s) is not same the other attachments (%s).",
3578 i, attachment_index, string_VkBlendOp(attachment_state.colorBlendOp),
3579 string_VkBlendOp(first_color_blend_op));
3580 }
ziga-lunarga283d022021-08-04 18:35:23 +02003581 }
sjfricke69877a72022-08-10 09:20:01 +09003582
3583 if (IsAdvanceBlendOperation(attachment_state.alphaBlendOp)) {
3584 advance_blend = true;
3585 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendIndependentBlend ==
3586 VK_FALSE &&
3587 attachment_state.alphaBlendOp != first_alpha_blend_op) {
3588 skip |= LogError(
3589 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendIndependentBlend-01408",
3590 "vkCreateGraphicsPipelines: advancedBlendIndependentBlend is set to VK_FALSE, but "
3591 "pCreateInfos[%" PRIu32 "].pColorBlendState->pAttachments[%" PRIu32
3592 "].alphaBlendOp (%s) is not same the other attachments (%s).",
3593 i, attachment_index, string_VkBlendOp(attachment_state.alphaBlendOp),
3594 string_VkBlendOp(first_alpha_blend_op));
3595 }
3596 }
3597
3598 if (advance_blend) {
3599 if (attachment_state.colorBlendOp != attachment_state.alphaBlendOp) {
3600 skip |= LogError(device, "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-01406",
3601 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3602 "].pColorBlendState->pAttachments[%" PRIu32
3603 "] has different colorBlendOp (%s) and alphaBlendOp (%s) but one of "
3604 "them is an advance blend operation.",
3605 i, attachment_index, string_VkBlendOp(attachment_state.colorBlendOp),
3606 string_VkBlendOp(attachment_state.alphaBlendOp));
ziga-lunargb2d507e2022-09-21 02:58:52 +02003607 } else if (color_attachment_count >
sjfricke69877a72022-08-10 09:20:01 +09003608 phys_dev_ext_props.blend_operation_advanced_props.advancedBlendMaxColorAttachments) {
3609 // color_attachment_count is found one of multiple spots above
3610 //
3611 // error can guarantee it is the same VkBlendOp
3612 skip |= LogError(
3613 device, "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-01410",
3614 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3615 "].pColorBlendState->pAttachments[%" PRIu32
3616 "] has an advance blend operation (%s) but the colorAttachmentCount (%" PRIu32
3617 ") for the subpass is greater than advancedBlendMaxColorAttachments (%" PRIu32 ").",
3618 i, attachment_index, string_VkBlendOp(attachment_state.colorBlendOp),
3619 color_attachment_count,
3620 phys_dev_ext_props.blend_operation_advanced_props.advancedBlendMaxColorAttachments);
3621 }
ziga-lunarga283d022021-08-04 18:35:23 +02003622 }
3623 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003624 }
3625 }
3626
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003627 if (create_info.pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003628 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003629 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3630 "].pColorBlendState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003631 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3632 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003633 }
3634
3635 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003636 if (create_info.pColorBlendState->logicOpEnable == VK_TRUE) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003637 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003638 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003639 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003640 AllVkLogicOpEnums, create_info.pColorBlendState->logicOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003641 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003642 }
3643 }
3644 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003645
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003646 const VkPipelineCreateFlags flags = create_info.flags;
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003647 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003648 if (create_info.basePipelineIndex != -1) {
3649 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003650 skip |=
3651 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003652 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3653 "]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003654 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003655 "and pCreateInfos->basePipelineIndex is not -1.",
3656 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003657 }
3658 }
3659
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003660 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
3661 if (create_info.basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003662 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003663 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3664 "]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003665 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003666 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3667 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003668 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003669 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003670 if (static_cast<uint32_t>(create_info.basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003671 skip |=
3672 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003673 "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32
3674 ") must be a valid"
3675 "index into the pCreateInfos array, of size %" PRIu32 ".",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003676 i, create_info.basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003677 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003678 }
3679 }
3680
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003681 if (create_info.pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003682 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003683 if (create_info.pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003684 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003685 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3686 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3687 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3688 "if the extension VK_NV_fill_rectangle is not enabled.");
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003689 } else if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003690 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003691 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003692 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003693 "pCreateInfos[%" PRIu32
3694 "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003695 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3696 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003697 }
3698 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003699 if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3700 (create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003701 (physical_device_features.fillModeNonSolid == false)) {
3702 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003703 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3704 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003705 "pCreateInfos[%" PRIu32
3706 "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003707 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3708 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003709 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003710 }
Petr Kraus299ba622017-11-24 03:09:03 +01003711
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003712 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003713 (create_info.pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003714 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3715 "The line width state is static (pCreateInfos[%" PRIu32
3716 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3717 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3718 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003719 i, i, create_info.pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003720 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003721 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003722
3723 // Validate no flags not allowed are used
3724 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003725 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003726 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3727 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003728 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3729 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003730 }
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003731 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library) &&
3732 (flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003733 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003734 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3735 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003736 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3737 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003738 }
3739 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3740 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003741 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3742 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003743 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3744 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003745 }
3746 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3747 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003748 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3749 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003750 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3751 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003752 }
3753 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3754 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003755 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3756 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003757 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3758 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003759 }
3760 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3761 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003762 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3763 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003764 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3765 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003766 }
3767 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3768 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003769 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3770 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003771 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3772 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003773 }
3774 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3775 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003776 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3777 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003778 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3779 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003780 }
3781 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3782 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003783 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3784 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003785 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3786 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003787 }
ziga-lunarg4bd42e42021-10-04 13:19:29 +02003788 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3789 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-04947",
3790 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3791 "]->flags (0x%x) must not include "
3792 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3793 i, flags);
3794 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003795 }
3796 }
3797
3798 return skip;
3799}
3800
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003801bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3802 uint32_t createInfoCount,
3803 const VkComputePipelineCreateInfo *pCreateInfos,
3804 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003805 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003806 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003807 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003808 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003809 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003810 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003811 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Nathaniel Cesario29e12402022-03-14 09:45:23 -06003812 if (feedback_struct && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
3813 const auto feedback_count = feedback_struct->pipelineStageCreationFeedbackCount;
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06003814 if ((feedback_count != 0) && (feedback_count != 1)) {
Nathaniel Cesario29e12402022-03-14 09:45:23 -06003815 skip |= LogError(
3816 device, "VUID-VkComputePipelineCreateInfo-pipelineStageCreationFeedbackCount-06566",
3817 "vkCreateComputePipelines(): VkPipelineCreationFeedbackCreateInfo::pipelineStageCreationFeedbackCount (%" PRIu32
3818 ") is not 0 or 1 in pCreateInfos[%" PRIu32 "].",
3819 feedback_count, i);
3820 }
Peter Chen85366392019-05-14 15:20:11 -04003821 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003822
3823 // Make sure compute stage is selected
3824 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003825 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003826 "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32
3827 "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003828 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003829 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003830
sfricke-samsungeb549012021-04-16 01:25:51 -07003831 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3832 // Validate no flags not allowed are used
3833 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003834 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3835 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3836 "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3837 i, flags);
sfricke-samsungeb549012021-04-16 01:25:51 -07003838 }
3839 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3840 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003841 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3842 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003843 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3844 i, flags);
3845 }
3846 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3847 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003848 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3849 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003850 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3851 i, flags);
3852 }
3853 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3854 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003855 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3856 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003857 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3858 i, flags);
3859 }
3860 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3861 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003862 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3863 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003864 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3865 i, flags);
3866 }
3867 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3868 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003869 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3870 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003871 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3872 i, flags);
3873 }
3874 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3875 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003876 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3877 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003878 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3879 i, flags);
3880 }
3881 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3882 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003883 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3884 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003885 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3886 i, flags);
3887 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003888 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3889 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003890 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3891 "]->flags (0x%x) must not include "
ziga-lunargf51e65f2021-07-18 23:51:57 +02003892 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3893 i, flags);
3894 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003895 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3896 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003897 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3898 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003899 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3900 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003901 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003902 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3903 if (pCreateInfos[i].basePipelineIndex != -1) {
3904 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3905 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3906 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3907 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3908 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3909 i);
3910 }
3911 }
3912
3913 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3914 if (pCreateInfos[i].basePipelineIndex != -1) {
3915 skip |= LogError(
3916 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3917 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3918 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3919 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3920 i);
3921 }
3922 } else {
3923 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3924 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3925 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3926 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3927 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3928 }
3929 }
3930 }
ziga-lunargc6341372021-07-28 12:57:42 +02003931
3932 std::stringstream msg;
3933 msg << "pCreateInfos[%" << i << "].stage";
3934 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003935 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003936 return skip;
3937}
3938
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003939bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003940 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003941 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003942
3943 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003944 const auto &features = physical_device_features;
3945 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003946
John Zulauf71968502017-10-26 13:51:15 -06003947 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3948 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003949 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3950 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3951 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3952 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003953 }
3954
3955 // Anistropy cannot be enabled in sampler unless enabled as a feature
3956 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003957 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3958 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3959 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003960 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003961 }
John Zulauf71968502017-10-26 13:51:15 -06003962
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003963 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3964 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003965 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3966 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3967 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3968 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003969 }
3970 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003971 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3972 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3973 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3974 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003975 }
3976 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003977 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3978 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3979 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3980 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003981 }
3982 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3983 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3984 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3985 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003986 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3987 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3988 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3989 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3990 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3991 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003992 }
3993 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003994 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3995 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3996 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003997 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003998 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003999 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
4000 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
4001 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07004002 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004003 }
4004
4005 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02004006 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004007 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004008 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
4009 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07004010 if (sampler_reduction != nullptr) {
4011 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
sjfricke751b7092022-04-12 21:49:37 +09004012 skip |= LogError(device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
4013 "vkCreateSampler(): copmareEnable is true so the sampler reduction mode must be "
4014 "VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
sfricke-samsung85252fb2020-05-08 20:44:06 -07004015 }
4016 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004017 }
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02004018 if (sampler_reduction && sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
ziga-lunarg01be97a2022-05-01 14:30:39 +02004019 if (!IsExtEnabled(device_extensions.vk_ext_filter_cubic)) {
4020 if (pCreateInfo->magFilter == VK_FILTER_CUBIC_EXT || pCreateInfo->minFilter == VK_FILTER_CUBIC_EXT) {
4021 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01422",
4022 "vkCreateSampler(): sampler reduction mode is %s, magFilter is %s and minFilter is %s, but "
4023 "extension %s is not enabled.",
4024 string_VkSamplerReductionMode(sampler_reduction->reductionMode),
4025 string_VkFilter(pCreateInfo->magFilter), string_VkFilter(pCreateInfo->minFilter),
4026 VK_EXT_FILTER_CUBIC_EXTENSION_NAME);
4027 }
4028 }
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02004029 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004030
4031 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
4032 // valid VkBorderColor value
4033 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
4034 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
4035 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004036 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
4037 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004038 }
4039
John Zulauf275805c2017-10-26 15:34:49 -06004040 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07004041 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06004042 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
4043 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004044 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
4045 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
4046 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06004047 }
4048 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07004049
sfricke-samsungd91da4a2020-02-09 17:19:04 -08004050 // Check for valid Lod range
4051 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07004052 skip |=
4053 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
4054 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08004055 }
4056
4057 // Check mipLodBias to device limit
4058 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07004059 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
4060 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
4061 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08004062 }
4063
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004064 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07004065 if (sampler_conversion != nullptr) {
4066 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
4067 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
4068 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
4069 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004070 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07004071 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07004072 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
4073 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
4074 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
4075 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
4076 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
4077 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
4078 }
4079 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02004080
4081 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
4082 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
4083 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
4084 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
4085 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
4086 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
4087 }
4088 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
4089 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
4090 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
4091 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
4092 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
4093 }
4094 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
4095 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
4096 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
4097 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
4098 pCreateInfo->minLod, pCreateInfo->maxLod);
4099 }
4100 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
4101 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
4102 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
4103 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
4104 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
4105 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
4106 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
4107 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
4108 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
4109 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
4110 }
4111 if (pCreateInfo->anisotropyEnable) {
4112 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
4113 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
4114 "pCreateInfo->anisotropyEnable must be VK_FALSE");
4115 }
4116 if (pCreateInfo->compareEnable) {
4117 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
4118 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
4119 "pCreateInfo->compareEnable must be VK_FALSE");
4120 }
4121 if (pCreateInfo->unnormalizedCoordinates) {
4122 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
4123 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
4124 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
4125 }
4126 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004127
Piers Daniell833b9492021-11-20 11:47:10 -07004128 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
4129 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
4130 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
4131 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4132 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
4133 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
4134 }
4135 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
4136 if (!custom_create_info) {
4137 skip |= LogError(
4138 device, "VUID-VkSamplerCreateInfo-borderColor-04011",
4139 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
4140 "struct in pNext chain.\n",
4141 string_VkBorderColor(pCreateInfo->borderColor));
4142 } else {
4143 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
4144 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT &&
4145 !FormatIsSampledInt(custom_create_info->format)) ||
4146 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
4147 !FormatIsSampledFloat(custom_create_info->format)))) {
4148 skip |=
4149 LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
Tony-LunarG7337b312020-04-15 16:40:25 -06004150 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
4151 "whose type does not match\n",
4152 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
Piers Daniell833b9492021-11-20 11:47:10 -07004153 ;
4154 }
4155 }
4156 }
4157
4158 const auto *border_color_component_mapping =
4159 LvlFindInChain<VkSamplerBorderColorComponentMappingCreateInfoEXT>(pCreateInfo->pNext);
4160 if (border_color_component_mapping) {
4161 const auto *border_color_swizzle_features =
4162 LvlFindInChain<VkPhysicalDeviceBorderColorSwizzleFeaturesEXT>(device_createinfo_pnext);
4163 bool border_color_swizzle_features_enabled =
4164 border_color_swizzle_features && border_color_swizzle_features->borderColorSwizzle;
4165 if (!border_color_swizzle_features_enabled) {
4166 skip |= LogError(device, "VUID-VkSamplerBorderColorComponentMappingCreateInfoEXT-borderColorSwizzle-06437",
4167 "vkCreateSampler(): The borderColorSwizzle feature must be enabled to use "
4168 "VkPhysicalDeviceBorderColorSwizzleFeaturesEXT");
Tony-LunarG7337b312020-04-15 16:40:25 -06004169 }
4170 }
4171 }
4172
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004173 return skip;
4174}
4175
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004176bool StatelessValidation::ValidateMutableDescriptorTypeCreateInfo(const VkDescriptorSetLayoutCreateInfo &create_info,
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004177 const VkMutableDescriptorTypeCreateInfoEXT &mutable_create_info,
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004178 const char *func_name) const {
4179 bool skip = false;
4180
4181 for (uint32_t i = 0; i < create_info.bindingCount; ++i) {
4182 uint32_t mutable_type_count = 0;
4183 if (mutable_create_info.mutableDescriptorTypeListCount > i) {
4184 mutable_type_count = mutable_create_info.pMutableDescriptorTypeLists[i].descriptorTypeCount;
4185 }
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004186 if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_EXT) {
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004187 if (mutable_type_count == 0) {
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004188 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListEXT-descriptorTypeCount-04597",
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004189 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004190 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_EXT, but "
4191 "VkMutableDescriptorTypeCreateInfoEXT::pMutableDescriptorTypeLists[%" PRIu32
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004192 "].descriptorTypeCount is 0.",
4193 func_name, i, i);
4194 }
4195 } else {
4196 if (mutable_type_count > 0) {
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004197 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListEXT-descriptorTypeCount-04599",
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004198 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
4199 "].descriptorType is %s, but "
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004200 "VkMutableDescriptorTypeCreateInfoEXT::pMutableDescriptorTypeLists[%" PRIu32
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004201 "].descriptorTypeCount is not 0.",
4202 func_name, i, string_VkDescriptorType(create_info.pBindings[i].descriptorType), i);
4203 }
4204 }
4205 }
4206
4207 for (uint32_t j = 0; j < mutable_create_info.mutableDescriptorTypeListCount; ++j) {
4208 for (uint32_t k = 0; k < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
4209 switch (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]) {
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004210 case VK_DESCRIPTOR_TYPE_MUTABLE_EXT:
4211 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListEXT-pDescriptorTypes-04600",
4212 "%s: VkMutableDescriptorTypeCreateInfoEXT::pMutableDescriptorTypeLists[%" PRIu32
4213 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_EXT.",
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004214 func_name, j, k);
4215 break;
4216 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004217 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListEXT-pDescriptorTypes-04601",
4218 "%s: VkMutableDescriptorTypeCreateInfoEXT::pMutableDescriptorTypeLists[%" PRIu32
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004219 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.",
4220 func_name, j, k);
4221 break;
4222 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004223 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListEXT-pDescriptorTypes-04602",
4224 "%s: VkMutableDescriptorTypeCreateInfoEXT::pMutableDescriptorTypeLists[%" PRIu32
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004225 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC.",
4226 func_name, j, k);
4227 break;
4228 case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT:
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004229 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListEXT-pDescriptorTypes-04603",
4230 "%s: VkMutableDescriptorTypeCreateInfoEXT::pMutableDescriptorTypeLists[%" PRIu32
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004231 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.",
4232 func_name, j, k);
4233 break;
4234 default:
4235 break;
4236 }
4237 for (uint32_t l = k + 1; l < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++l) {
4238 if (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k] ==
4239 mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[l]) {
4240 skip |=
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004241 LogError(device, "VUID-VkMutableDescriptorTypeListEXT-pDescriptorTypes-04598",
4242 "%s: VkMutableDescriptorTypeCreateInfoEXT::pMutableDescriptorTypeLists[%" PRIu32
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004243 "].pDescriptorTypes[%" PRIu32
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004244 "] and VkMutableDescriptorTypeCreateInfoEXT::pMutableDescriptorTypeLists[%" PRIu32
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004245 "].pDescriptorTypes[%" PRIu32 "] are both %s.",
4246 func_name, j, k, j, l,
4247 string_VkDescriptorType(mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]));
4248 }
4249 }
4250 }
4251 }
4252
4253 return skip;
4254}
4255
Tony-LunarG115f89d2022-06-15 10:53:22 -06004256#ifdef VK_USE_PLATFORM_METAL_EXT
4257bool StatelessValidation::ExportMetalObjectsPNextUtil(VkExportMetalObjectTypeFlagBitsEXT bit, const char *vuid,
4258 const char *api_call, const char *sType, const void *pNext) const {
4259 bool skip = false;
4260 auto export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(pNext);
4261 while (export_metal_object_info) {
4262 if (export_metal_object_info->exportObjectType != bit) {
4263 std::stringstream message;
4264 message << api_call
4265 << " The pNext chain contains a VkExportMetalObjectCreateInfoEXT whose "
4266 "exportObjectType = %s, but only VkExportMetalObjectCreateInfoEXT structs with exportObjectType of "
4267 << sType << " are allowed";
4268 skip |= LogError(device, vuid, message.str().c_str(),
4269 string_VkExportMetalObjectTypeFlagBitsEXT(export_metal_object_info->exportObjectType));
4270 }
4271 export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(export_metal_object_info->pNext);
4272 }
4273 return skip;
4274}
4275#endif // VK_USE_PLATFORM_METAL_EXT
4276
4277bool StatelessValidation::manual_PreCallValidateCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo *pCreateInfo,
4278 const VkAllocationCallbacks *pAllocator,
4279 VkSemaphore *pSemaphore) const {
4280 bool skip = false;
4281#ifdef VK_USE_PLATFORM_METAL_EXT
4282 skip |= ExportMetalObjectsPNextUtil(
4283 VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT, "VUID-VkSemaphoreCreateInfo-pNext-06789",
4284 "vkCreateSemaphore():", "VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT", pCreateInfo->pNext);
4285#endif // VK_USE_PLATFORM_METAL_EXT
4286 return skip;
4287}
4288bool StatelessValidation::manual_PreCallValidateCreateEvent(VkDevice device, const VkEventCreateInfo *pCreateInfo,
4289 const VkAllocationCallbacks *pAllocator, VkEvent *pEvent) const {
4290 bool skip = false;
4291#ifdef VK_USE_PLATFORM_METAL_EXT
4292 skip |= ExportMetalObjectsPNextUtil(
4293 VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT, "VUID-VkEventCreateInfo-pNext-06790",
4294 "vkCreateEvent():", "VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT", pCreateInfo->pNext);
4295#endif // VK_USE_PLATFORM_METAL_EXT
4296 return skip;
4297}
4298bool StatelessValidation::manual_PreCallValidateCreateBufferView(VkDevice device, const VkBufferViewCreateInfo *pCreateInfo,
4299 const VkAllocationCallbacks *pAllocator,
4300 VkBufferView *pBufferView) const {
4301 bool skip = false;
4302#ifdef VK_USE_PLATFORM_METAL_EXT
4303 skip |= ExportMetalObjectsPNextUtil(
4304 VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT, "VUID-VkBufferViewCreateInfo-pNext-06782",
4305 "vkCreateBufferView():", "VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT", pCreateInfo->pNext);
4306#endif // VK_USE_PLATFORM_METAL_EXT
4307 return skip;
4308}
4309
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004310bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
4311 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
4312 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004313 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004314 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004315
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004316 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoEXT>(pCreateInfo->pNext);
4317 const auto *mutable_descriptor_type_features =
4318 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT>(device_createinfo_pnext);
ziga-lunargfc6896f2021-10-15 18:46:12 +02004319 bool mutable_descriptor_type_features_enabled =
4320 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
4321
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004322 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
sjfricke9c08a432022-08-20 13:45:34 +09004323 if (pCreateInfo->pBindings != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004324 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
4325 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004326 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4327 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
4328 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
4329 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
4330 ++descriptor_index) {
4331 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07004332 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004333 "vkCreateDescriptorSetLayout: required parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004334 "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32
4335 "] specified as VK_NULL_HANDLE",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004336 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004337 }
4338 }
4339 }
4340
4341 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
4342 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
4343 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004344 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004345 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4346 "].descriptorCount is not 0, "
4347 "pCreateInfo->pBindings[%" PRIu32
4348 "].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004349 "values.",
4350 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004351 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004352
4353 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
4354 (pCreateInfo->pBindings[i].stageFlags != 0) &&
4355 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004356 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
4357 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4358 "].descriptorCount is not 0 and "
4359 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32
4360 "].stageFlags "
4361 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
4362 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004363 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004364
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004365 if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_EXT) {
Mike Schuchardt360165e2022-09-02 11:19:04 -07004366 if (mutable_descriptor_type) {
4367 if (i >= mutable_descriptor_type->mutableDescriptorTypeListCount) {
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004368 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-pBindings-07303",
Mike Schuchardt360165e2022-09-02 11:19:04 -07004369 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004370 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_EXT but "
4371 "VkMutableDescriptorTypeCreateInfoEXT::mutableDescriptorTypeListCount is %" PRIu32
Mike Schuchardt360165e2022-09-02 11:19:04 -07004372 " (not large enough to contain index %" PRIu32 ")",
4373 i, mutable_descriptor_type->mutableDescriptorTypeListCount, i);
4374 }
4375 } else {
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004376 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-pBindings-07303",
ziga-lunargfc6896f2021-10-15 18:46:12 +02004377 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004378 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_EXT but "
4379 "VkMutableDescriptorTypeCreateInfoEXT is not included in the pNext chain.",
ziga-lunargfc6896f2021-10-15 18:46:12 +02004380 i);
4381 }
4382 if (pCreateInfo->pBindings[i].pImmutableSamplers) {
4383 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594",
4384 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004385 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_EXT but "
ziga-lunargfc6896f2021-10-15 18:46:12 +02004386 "pImmutableSamplers is not NULL.",
4387 i);
4388 }
4389 if (!mutable_descriptor_type_features_enabled) {
4390 skip |= LogError(
4391 device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595",
4392 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004393 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_EXT but "
4394 "VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT::mutableDescriptorType feature is not enabled.",
ziga-lunargfc6896f2021-10-15 18:46:12 +02004395 i);
4396 }
4397 }
4398
4399 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR &&
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004400 pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_EXT) {
ziga-lunargfc6896f2021-10-15 18:46:12 +02004401 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591",
4402 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4403 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004404 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_EXT.",
4405 i);
ziga-lunargfc6896f2021-10-15 18:46:12 +02004406 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004407 }
4408 }
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004409
4410 if (mutable_descriptor_type) {
paul-lunargef8ed7c2022-07-14 13:42:53 -06004411 skip |=
4412 ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type, "vkDescriptorSetLayoutCreateInfo");
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004413 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004414 }
sjfricke9c08a432022-08-20 13:45:34 +09004415
4416 // TODO - Remove these 2 extension checks once the enum-to-extensions logic is generated
4417 // mostly likely will fail test trying to hit these
4418 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR &&
4419 !IsExtEnabled(device_extensions.vk_khr_push_descriptor)) {
4420 skip |= LogError(
4421 device, kVUID_Core_DrawState_ExtensionNotEnabled,
4422 "vkCreateDescriptorSetLayout(): Attempted to use %s in %s but its required extension %s has not been enabled.\n",
4423 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR", "VkDescriptorSetLayoutCreateInfo::flags",
4424 VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
4425 }
4426 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT &&
4427 !IsExtEnabled(device_extensions.vk_ext_descriptor_indexing)) {
4428 skip |= LogError(
4429 device, kVUID_Core_DrawState_ExtensionNotEnabled,
4430 "vkCreateDescriptorSetLayout(): Attemped to use %s in %s but its required extension %s has not been enabled.\n",
4431 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT", "VkDescriptorSetLayoutCreateInfo::flags",
4432 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
4433 }
4434
4435 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) &&
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004436 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_EXT)) {
sjfricke9c08a432022-08-20 13:45:34 +09004437 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590",
4438 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4439 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and "
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004440 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_EXT.");
sjfricke9c08a432022-08-20 13:45:34 +09004441 }
4442 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) &&
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004443 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_EXT)) {
sjfricke9c08a432022-08-20 13:45:34 +09004444 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592",
4445 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4446 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and "
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004447 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_EXT.");
sjfricke9c08a432022-08-20 13:45:34 +09004448 }
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004449 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_EXT && !mutable_descriptor_type_features_enabled) {
sjfricke9c08a432022-08-20 13:45:34 +09004450 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596",
4451 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
Mike Schuchardt2d523e52022-09-15 12:25:58 -07004452 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_EXT, but "
4453 "VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT::mutableDescriptorType feature is not enabled.");
ziga-lunargfc6896f2021-10-15 18:46:12 +02004454 }
4455
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004456 return skip;
4457}
4458
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004459bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
4460 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004461 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004462 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4463 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4464 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004465 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
4466 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004467}
4468
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004469bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
4470 const VkWriteDescriptorSet *pDescriptorWrites,
Mike Schuchardt979898a2022-01-11 10:46:59 -08004471 const bool isPushDescriptor) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004472 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004473
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004474 if (pDescriptorWrites != NULL) {
4475 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
4476 // descriptorCount must be greater than 0
4477 if (pDescriptorWrites[i].descriptorCount == 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004478 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
4479 "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.",
4480 vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004481 }
4482
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004483 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
Mike Schuchardt979898a2022-01-11 10:46:59 -08004484 if (!isPushDescriptor) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004485 // dstSet must be a valid VkDescriptorSet handle
4486 skip |= validate_required_handle(vkCallingFunction,
4487 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
4488 pDescriptorWrites[i].dstSet);
4489 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004490
4491 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4492 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
4493 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4494 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4495 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004496 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004497 if (!isPushDescriptor) {
4498 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4499 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or
4500 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pImageInfo must be a pointer to an array of descriptorCount valid
4501 // VkDescriptorImageInfo structures. Valid imageView handles are checked in
4502 // ObjectLifetimes::ValidateDescriptorWrite.
4503 skip |= LogError(
4504 device, "VUID-vkUpdateDescriptorSets-pDescriptorWrites-06493",
4505 "%s(): if pDescriptorWrites[%" PRIu32
4506 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
4507 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
4508 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
4509 vkCallingFunction, i, i);
4510 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4511 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4512 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
4513 // If called from vkCmdPushDescriptorSetKHR, pImageInfo is only requred for descriptor types
4514 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, and
4515 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
4516 skip |= LogError(device, "VUID-vkCmdPushDescriptorSetKHR-pDescriptorWrites-06494",
4517 "%s(): if pDescriptorWrites[%" PRIu32
4518 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE "
4519 "or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32
4520 "].pImageInfo must not be NULL.",
4521 vkCallingFunction, i, i);
4522 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004523 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
4524 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05004525 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
4526 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004527 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4528 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004529 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004530 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
4531 ParameterName::IndexVector{i, descriptor_index}),
4532 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06004533 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004534 }
4535 }
4536 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4537 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4538 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
4539 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
4540 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4541 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
4542 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05004543 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004544 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004545 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004546 "%s(): if pDescriptorWrites[%" PRIu32
4547 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004548 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
4549 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004550 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004551 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004552 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05004553 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004554 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05004555 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004556 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4557 ++descriptor_index) {
4558 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
4559 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
4560 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004561 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004562 "%s(): if pDescriptorWrites[%" PRIu32
4563 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01004564 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004565 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
4566 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05004567 }
4568 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004569 }
4570 }
4571 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
4572 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004573 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004574 }
4575
4576 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4577 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004578 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004579 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4580 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004581 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004582 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004583 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004584 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004585 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004586 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004587 }
4588 }
4589 }
4590 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4591 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004592 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004593 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4594 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004595 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004596 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004597 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004598 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004599 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004600 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004601 }
4602 }
4603 }
4604 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004605 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
4606 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08004607 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004608 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004609 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4610 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
4611 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
4612 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004613 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004614 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4615 pDescriptorWrites[i].descriptorCount);
4616 }
4617 // further checks only if we have right structtype
4618 if (pnext_struct) {
4619 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4620 skip |= LogError(
4621 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004622 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4623 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004624 ".",
4625 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07004626 }
sourav parmarbcee7512020-12-28 14:34:49 -08004627 if (pnext_struct->accelerationStructureCount == 0) {
4628 skip |= LogError(device,
4629 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004630 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004631 }
4632 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004633 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004634 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4635 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4636 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4637 skip |= LogError(device,
4638 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
4639 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004640 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004641 }
4642 }
4643 }
sourav parmarbcee7512020-12-28 14:34:49 -08004644 }
4645 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004646 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004647 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4648 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
4649 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
4650 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004651 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004652 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4653 pDescriptorWrites[i].descriptorCount);
4654 }
4655 // further checks only if we have right structtype
4656 if (pnext_struct) {
4657 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4658 skip |= LogError(
4659 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004660 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4661 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004662 ".",
4663 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07004664 }
sourav parmarbcee7512020-12-28 14:34:49 -08004665 if (pnext_struct->accelerationStructureCount == 0) {
4666 skip |= LogError(device,
4667 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004668 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004669 }
4670 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004671 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004672 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4673 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4674 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4675 skip |= LogError(device,
4676 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
4677 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004678 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004679 }
4680 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004681 }
4682 }
4683 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004684 }
4685 }
4686 return skip;
4687}
4688
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004689bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
4690 const VkWriteDescriptorSet *pDescriptorWrites,
4691 uint32_t descriptorCopyCount,
4692 const VkCopyDescriptorSet *pDescriptorCopies) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004693 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites, false);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004694}
4695
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004696bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004697 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004698 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004699 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
4700}
4701
sfricke-samsung681ab7b2020-10-29 01:53:35 -07004702bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
4703 const VkAllocationCallbacks *pAllocator,
4704 VkRenderPass *pRenderPass) const {
4705 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4706}
4707
Mike Schuchardt2df08912020-12-15 16:28:09 -08004708bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004709 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004710 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004711 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4712}
4713
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004714bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
4715 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004716 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004717 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004718
4719 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4720 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4721 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004722 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
4723 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004724 return skip;
4725}
4726
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004727bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004728 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004729 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02004730
4731 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
4732 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07004733 bool cb_is_secondary;
4734 {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06004735 auto lock = CBReadLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07004736 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
4737 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004738
Tony-LunarG3c287f62020-12-17 12:39:49 -07004739 if (cb_is_secondary) {
4740 // Implicit VUs
4741 // validate only sType here; pointer has to be validated in core_validation
4742 const bool k_not_required = false;
4743 const char *k_no_vuid = nullptr;
4744 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
4745 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004746 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
4747 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004748
Tony-LunarG3c287f62020-12-17 12:39:49 -07004749 if (info) {
4750 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07004751 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
amhagana448ea52021-11-02 14:09:14 -04004752 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
4753 VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD,
David Zhao Akeley44139b12021-04-26 16:16:13 -07004754 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004755 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004756 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4757 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4758 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4759 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004760
Tony-LunarG3c287f62020-12-17 12:39:49 -07004761 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004762
Tony-LunarG3c287f62020-12-17 12:39:49 -07004763 // Explicit VUs
4764 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004765 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004766 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4767 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4768 cmd_name);
4769 }
4770
4771 if (physical_device_features.inheritedQueries) {
4772 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004773 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4774 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4775 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004776 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004777 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004778 }
4779
4780 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004781 skip |=
4782 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4783 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4784 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4785 } else { // !pipelineStatisticsQuery
4786 skip |=
4787 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4788 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004789 }
4790
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004791 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004792 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004793 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004794 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4795 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4796 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004797 commandBuffer,
4798 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004799 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4800 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4801 }
Petr Kraus139757b2019-08-15 17:19:33 +02004802 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004803
4804 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4805 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4806 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4807 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4808 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4809 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4810 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4811 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4812 }
Petr Kraus139757b2019-08-15 17:19:33 +02004813 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004814 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004815 return skip;
4816}
4817
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004818bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004819 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004820 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004821
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004822 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004823 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004824 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4825 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4826 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004827 }
4828 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004829 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4830 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4831 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004832 }
4833 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004834 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004835 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004836 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4837 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4838 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4839 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004840 }
4841 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004842
4843 if (pViewports) {
4844 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4845 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004846 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004847 skip |= manual_PreCallValidateViewport(
4848 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004849 }
4850 }
4851
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004852 return skip;
4853}
4854
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004855bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004856 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004857 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004858
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004859 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004860 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004861 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4862 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4863 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004864 }
4865 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004866 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4867 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4868 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004869 }
4870 } else { // multiViewport enabled
4871 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004872 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004873 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4874 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4875 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4876 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004877 }
4878 }
4879
Petr Kraus6260f0a2018-02-27 21:15:55 +01004880 if (pScissors) {
4881 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4882 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004883
Petr Kraus6260f0a2018-02-27 21:15:55 +01004884 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004885 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4886 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4887 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004888 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004889
Petr Kraus6260f0a2018-02-27 21:15:55 +01004890 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004891 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4892 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4893 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004894 }
4895
4896 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4897 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004898 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4899 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4900 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4901 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004902 }
4903
4904 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4905 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004906 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4907 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4908 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4909 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004910 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004911 }
4912 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004913
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004914 return skip;
4915}
4916
Jeff Bolz5c801d12019-10-09 10:38:45 -05004917bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004918 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004919
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004920 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004921 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4922 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004923 }
4924
4925 return skip;
4926}
4927
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004928bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004929 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004930 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004931
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004932 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004933 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sjfricke91d9bda2022-08-01 21:44:17 +09004934 "vkCmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004935 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004936 }
4937 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004938 skip |=
4939 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
sjfricke91d9bda2022-08-01 21:44:17 +09004940 "vkCmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004941 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004942 }
sjfricke91d9bda2022-08-01 21:44:17 +09004943 if (offset & 3) {
4944 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-offset-02710",
4945 "vkCmdDrawIndirect(): offset (%" PRIxLEAST64 ") must be a multiple of 4.", offset);
4946 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004947 return skip;
4948}
4949
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004950bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004951 VkDeviceSize offset, uint32_t drawCount,
4952 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004953 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004954 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sjfricke91d9bda2022-08-01 21:44:17 +09004955 skip |= LogError(
4956 device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4957 "vkCmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4958 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004959 }
4960 if (drawCount > device_limits.maxDrawIndirectCount) {
4961 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sjfricke91d9bda2022-08-01 21:44:17 +09004962 "vkCmdDrawIndexedIndirect(): drawCount (%" PRIu32
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004963 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004964 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004965 }
sjfricke91d9bda2022-08-01 21:44:17 +09004966 if (offset & 3) {
4967 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-offset-02710",
4968 "vkCmdDrawIndexedIndirect(): offset (%" PRIxLEAST64 ") must be a multiple of 4.", offset);
4969 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004970 return skip;
4971}
4972
sfricke-samsungf692b972020-05-02 08:00:45 -07004973bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
sjfricke91d9bda2022-08-01 21:44:17 +09004974 VkDeviceSize countBufferOffset, CMD_TYPE cmd_type) const {
sfricke-samsungf692b972020-05-02 08:00:45 -07004975 bool skip = false;
sfricke-samsungf692b972020-05-02 08:00:45 -07004976 if (offset & 3) {
4977 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
sjfricke91d9bda2022-08-01 21:44:17 +09004978 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4979 CommandTypeString(cmd_type), offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004980 }
4981
4982 if (countBufferOffset & 3) {
4983 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
sjfricke91d9bda2022-08-01 21:44:17 +09004984 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4985 CommandTypeString(cmd_type), countBufferOffset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004986 }
4987 return skip;
4988}
4989
4990bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4991 VkDeviceSize offset, VkBuffer countBuffer,
4992 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4993 uint32_t stride) const {
sjfricke91d9bda2022-08-01 21:44:17 +09004994 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, CMD_DRAWINDIRECTCOUNT);
4995}
4996
4997bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer,
4998 VkDeviceSize offset, VkBuffer countBuffer,
4999 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
5000 uint32_t stride) const {
5001 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, CMD_DRAWINDIRECTCOUNTAMD);
sfricke-samsungf692b972020-05-02 08:00:45 -07005002}
5003
5004bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
5005 VkDeviceSize offset, VkBuffer countBuffer,
5006 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
5007 uint32_t stride) const {
sjfricke91d9bda2022-08-01 21:44:17 +09005008 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, CMD_DRAWINDIRECTCOUNTKHR);
sfricke-samsungf692b972020-05-02 08:00:45 -07005009}
5010
5011bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
sjfricke91d9bda2022-08-01 21:44:17 +09005012 VkDeviceSize countBufferOffset, CMD_TYPE cmd_type) const {
sfricke-samsungf692b972020-05-02 08:00:45 -07005013 bool skip = false;
sfricke-samsungf692b972020-05-02 08:00:45 -07005014 if (offset & 3) {
5015 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
sjfricke91d9bda2022-08-01 21:44:17 +09005016 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5017 CommandTypeString(cmd_type), offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07005018 }
5019
5020 if (countBufferOffset & 3) {
5021 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
sjfricke91d9bda2022-08-01 21:44:17 +09005022 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5023 CommandTypeString(cmd_type), countBufferOffset);
sfricke-samsungf692b972020-05-02 08:00:45 -07005024 }
5025 return skip;
5026}
5027
5028bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
5029 VkDeviceSize offset, VkBuffer countBuffer,
5030 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
5031 uint32_t stride) const {
sjfricke91d9bda2022-08-01 21:44:17 +09005032 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, CMD_DRAWINDEXEDINDIRECTCOUNT);
5033}
5034
5035bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer,
5036 VkDeviceSize offset, VkBuffer countBuffer,
5037 VkDeviceSize countBufferOffset,
5038 uint32_t maxDrawCount, uint32_t stride) const {
5039 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, CMD_DRAWINDEXEDINDIRECTCOUNTAMD);
sfricke-samsungf692b972020-05-02 08:00:45 -07005040}
5041
5042bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
5043 VkDeviceSize offset, VkBuffer countBuffer,
5044 VkDeviceSize countBufferOffset,
5045 uint32_t maxDrawCount, uint32_t stride) const {
sjfricke91d9bda2022-08-01 21:44:17 +09005046 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, CMD_DRAWINDEXEDINDIRECTCOUNTKHR);
sfricke-samsungf692b972020-05-02 08:00:45 -07005047}
5048
Tony-LunarG4490de42021-06-21 15:49:19 -06005049bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
5050 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
5051 uint32_t firstInstance, uint32_t stride) const {
5052 bool skip = false;
5053 if (stride & 3) {
5054 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
5055 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
5056 }
5057 if (drawCount && nullptr == pVertexInfo) {
5058 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
5059 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
5060 "one or more valid instances of VkMultiDrawInfoEXT structures");
5061 }
5062 return skip;
5063}
5064
5065bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
5066 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
5067 uint32_t instanceCount, uint32_t firstInstance,
5068 uint32_t stride, const int32_t *pVertexOffset) const {
5069 bool skip = false;
5070 if (stride & 3) {
5071 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
5072 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
5073 }
5074 if (drawCount && nullptr == pIndexInfo) {
5075 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
5076 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
5077 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
5078 }
5079 return skip;
5080}
5081
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06005082bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
5083 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005084 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06005085 bool skip = false;
5086 for (uint32_t rect = 0; rect < rectCount; rect++) {
5087 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005088 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005089 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06005090 }
sfricke-samsung10867682020-04-25 02:20:39 -07005091 if (pRects[rect].rect.extent.width == 0) {
5092 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005093 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07005094 }
5095 if (pRects[rect].rect.extent.height == 0) {
5096 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005097 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07005098 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06005099 }
5100 return skip;
5101}
5102
Andrew Fobel3abeb992020-01-20 16:33:22 -05005103bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
5104 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
5105 VkImageFormatProperties2 *pImageFormatProperties,
5106 const char *apiName) const {
5107 bool skip = false;
5108
5109 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005110 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05005111 if (image_stencil_struct != nullptr) {
5112 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
5113 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
5114 // No flags other than the legal attachment bits may be set
5115 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
5116 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005117 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
5118 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
5119 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
5120 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
5121 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05005122 }
5123 }
5124 }
ziga-lunargd3da2532021-08-11 11:50:12 +02005125 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
5126 if (image_drm_format) {
5127 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
5128 skip |= LogError(
5129 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
5130 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
5131 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
5132 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
5133 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02005134 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
5135 skip |= LogError(
5136 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
5137 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
5138 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
5139 apiName, image_drm_format->queueFamilyIndexCount);
5140 }
ziga-lunargd3da2532021-08-11 11:50:12 +02005141 } else {
5142 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
5143 skip |= LogError(
5144 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
5145 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
5146 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
5147 apiName);
5148 }
5149 }
5150 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
5151 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
5152 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
5153 if (!format_list || format_list->viewFormatCount == 0) {
5154 skip |= LogError(
5155 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
5156 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
5157 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
5158 apiName);
5159 }
5160 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05005161 }
5162
5163 return skip;
5164}
5165
5166bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
5167 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
5168 VkImageFormatProperties2 *pImageFormatProperties) const {
5169 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
5170 "vkGetPhysicalDeviceImageFormatProperties2");
5171}
5172
5173bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
5174 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
5175 VkImageFormatProperties2 *pImageFormatProperties) const {
5176 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
5177 "vkGetPhysicalDeviceImageFormatProperties2KHR");
5178}
5179
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03005180bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
5181 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
5182 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
5183 bool skip = false;
5184
5185 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
5186 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
5187 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
5188 }
5189
5190 return skip;
5191}
5192
sfricke-samsung3999ef62020-02-09 17:05:59 -08005193bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
5194 uint32_t regionCount, const VkBufferCopy *pRegions) const {
5195 bool skip = false;
5196
5197 if (pRegions != nullptr) {
5198 for (uint32_t i = 0; i < regionCount; i++) {
5199 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005200 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005201 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08005202 }
5203 }
5204 }
5205 return skip;
5206}
5207
Jeff Leger178b1e52020-10-05 12:22:23 -04005208bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
5209 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
5210 bool skip = false;
5211
5212 if (pCopyBufferInfo->pRegions != nullptr) {
5213 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
5214 if (pCopyBufferInfo->pRegions[i].size == 0) {
Tony-LunarGef035472021-11-02 10:23:33 -06005215 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005216 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04005217 }
5218 }
5219 }
5220 return skip;
5221}
5222
Tony-LunarGef035472021-11-02 10:23:33 -06005223bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2(VkCommandBuffer commandBuffer,
5224 const VkCopyBufferInfo2 *pCopyBufferInfo) const {
5225 bool skip = false;
5226
5227 if (pCopyBufferInfo->pRegions != nullptr) {
5228 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
5229 if (pCopyBufferInfo->pRegions[i].size == 0) {
5230 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
5231 "vkCmdCopyBuffer2() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
5232 }
5233 }
5234 }
5235 return skip;
5236}
5237
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005238bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005239 VkDeviceSize dstOffset, VkDeviceSize dataSize,
5240 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005241 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005242
5243 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005244 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
5245 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5246 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005247 }
5248
5249 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005250 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
5251 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
5252 "), must be greater than zero and less than or equal to 65536.",
5253 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005254 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005255 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
5256 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5257 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005258 }
5259 return skip;
5260}
5261
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005262bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005263 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005264 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005265
5266 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005267 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
5268 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5269 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005270 }
5271
5272 if (size != VK_WHOLE_SIZE) {
5273 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005274 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005275 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
5276 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005277 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005278 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
5279 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005280 }
5281 }
5282 return skip;
5283}
5284
sfricke-samsunga1d00272021-03-10 21:37:41 -08005285bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005286 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005287
5288 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005289 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5290 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
5291 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
5292 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005293 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005294 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
5295 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
5296 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005297 }
5298
5299 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
5300 // queueFamilyIndexCount uint32_t values
5301 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005302 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005303 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005304 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08005305 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
5306 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005307 }
5308 }
5309
Dave Houlton413a6782018-05-22 13:01:54 -06005310 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005311 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005312
sfricke-samsunga1d00272021-03-10 21:37:41 -08005313 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
5314 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
5315 if (format_list_info) {
5316 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
5317 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
5318 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
5319 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005320 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
5321 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005322 func_name, viewFormatCount);
5323 }
5324
5325 // Using the first format, compare the rest of the formats against it that they are compatible
5326 for (uint32_t i = 1; i < viewFormatCount; i++) {
5327 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
5328 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
5329 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
5330 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005331 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
5332 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005333 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
5334 string_VkFormat(format_list_info->pViewFormats[i]));
5335 }
5336 }
5337 }
5338
5339 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
5340 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
5341 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
5342 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
5343 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
5344 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
5345 func_name);
5346 } else {
5347 if (format_list_info == nullptr) {
5348 skip |= LogError(
5349 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5350 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
5351 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
5352 func_name);
5353 } else if (format_list_info->viewFormatCount == 0) {
5354 skip |= LogError(
5355 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5356 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
5357 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
5358 func_name);
5359 } else {
5360 bool found_base_format = false;
5361 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
5362 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
5363 found_base_format = true;
5364 break;
5365 }
5366 }
5367 if (!found_base_format) {
5368 skip |=
5369 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5370 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
5371 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
5372 "pCreateInfo->imageFormat.",
5373 func_name);
5374 }
5375 }
5376 }
5377 }
5378 }
5379 return skip;
5380}
5381
5382bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
5383 const VkAllocationCallbacks *pAllocator,
5384 VkSwapchainKHR *pSwapchain) const {
5385 bool skip = false;
5386 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
5387 return skip;
5388}
5389
5390bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
5391 const VkSwapchainCreateInfoKHR *pCreateInfos,
5392 const VkAllocationCallbacks *pAllocator,
5393 VkSwapchainKHR *pSwapchains) const {
5394 bool skip = false;
5395 if (pCreateInfos) {
5396 for (uint32_t i = 0; i < swapchainCount; i++) {
5397 std::stringstream func_name;
5398 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
5399 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
5400 }
5401 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005402 return skip;
5403}
5404
Jeff Bolz5c801d12019-10-09 10:38:45 -05005405bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005406 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005407
5408 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005409 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06005410 if (present_regions) {
5411 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07005412 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06005413 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
5414 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07005415 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005416 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
5417 "extension swapchainCount is %i. These values must be equal.",
5418 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06005419 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005420 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08005421 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
5422 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005423 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
5424 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
5425 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06005426 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005427 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005428 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06005429 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005430 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005431 }
5432 }
5433
5434 return skip;
5435}
5436
sfricke-samsung5c1b7392020-12-13 22:17:15 -08005437bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
5438 const VkDisplayModeCreateInfoKHR *pCreateInfo,
5439 const VkAllocationCallbacks *pAllocator,
5440 VkDisplayModeKHR *pMode) const {
5441 bool skip = false;
5442
5443 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
5444 if (display_mode_parameters.visibleRegion.width == 0) {
5445 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
5446 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
5447 }
5448 if (display_mode_parameters.visibleRegion.height == 0) {
5449 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
5450 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
5451 }
5452 if (display_mode_parameters.refreshRate == 0) {
5453 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
5454 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
5455 }
5456
5457 return skip;
5458}
5459
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005460#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005461bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
5462 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
5463 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005464 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005465 bool skip = false;
5466
5467 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005468 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
5469 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005470 }
5471
5472 return skip;
5473}
5474#endif // VK_USE_PLATFORM_WIN32_KHR
5475
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005476static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
5477 bool partial_overlap = false;
5478
5479 static const std::vector<VkDescriptorType> all_descriptor_types = {
5480 VK_DESCRIPTOR_TYPE_SAMPLER,
5481 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
5482 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
5483 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
5484 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
5485 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
5486 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
5487 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
5488 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
5489 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
5490 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
5491 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
5492 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
5493 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
5494 };
5495
Mike Schuchardt2d523e52022-09-15 12:25:58 -07005496 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoEXT>(pCreateInfo->pNext);
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005497 if (mutable_descriptor_type) {
5498 std::vector<VkDescriptorType> first_types, second_types;
5499 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
5500 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
5501 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
5502 }
5503 } else {
5504 first_types = all_descriptor_types;
5505 }
5506 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
5507 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
5508 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
5509 }
5510 } else {
5511 second_types = all_descriptor_types;
5512 }
5513
5514 bool complete_overlap = first_types.size() == second_types.size();
5515 bool disjoint = true;
5516 for (const auto first_type : first_types) {
5517 bool found = false;
5518 for (const auto second_type : second_types) {
5519 if (first_type == second_type) {
5520 found = true;
5521 break;
5522 }
5523 }
5524 if (found) {
5525 disjoint = false;
5526 } else {
5527 complete_overlap = false;
5528 }
5529 if (!disjoint && !complete_overlap) {
5530 partial_overlap = true;
5531 break;
5532 }
5533 }
5534 }
5535
5536 return partial_overlap;
5537}
5538
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005539bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005540 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005541 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02005542 bool skip = false;
5543
5544 if (pCreateInfo) {
5545 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005546 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
5547 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02005548 }
5549
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005550 const auto *mutable_descriptor_type_features =
Mike Schuchardt2d523e52022-09-15 12:25:58 -07005551 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT>(device_createinfo_pnext);
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005552 bool mutable_descriptor_type_enabled =
5553 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
5554
Petr Krausc8655be2017-09-27 18:56:51 +02005555 if (pCreateInfo->pPoolSizes) {
5556 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
5557 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005558 skip |= LogError(
5559 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005560 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02005561 }
Jeff Bolze54ae892018-09-08 12:16:29 -05005562 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
5563 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005564 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
5565 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5566 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
5567 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
5568 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05005569 }
Mike Schuchardt2d523e52022-09-15 12:25:58 -07005570 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_EXT && !mutable_descriptor_type_enabled) {
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005571 skip |=
5572 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
5573 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
Mike Schuchardt2d523e52022-09-15 12:25:58 -07005574 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_EXT "
5575 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT::mutableDescriptorType is not enabled.",
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005576 i);
5577 }
Mike Schuchardt2d523e52022-09-15 12:25:58 -07005578 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_EXT) {
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005579 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
Mike Schuchardt2d523e52022-09-15 12:25:58 -07005580 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_EXT) {
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005581 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
5582 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
5583 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5584 "].type and pCreateInfo->pPoolSizes[%" PRIu32
Mike Schuchardt2d523e52022-09-15 12:25:58 -07005585 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_EXT "
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005586 " and have sets which partially overlap.",
5587 i, j);
5588 }
5589 }
5590 }
5591 }
Petr Krausc8655be2017-09-27 18:56:51 +02005592 }
5593 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005594
Mike Schuchardt2d523e52022-09-15 12:25:58 -07005595 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_EXT && (!mutable_descriptor_type_enabled)) {
5596 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
5597 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_EXT, "
5598 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT::mutableDescriptorType is not enabled.");
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005599 }
Mike Schuchardt2d523e52022-09-15 12:25:58 -07005600 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_EXT) &&
ziga-lunarg0cf85212021-07-19 01:26:17 +02005601 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
5602 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
5603 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
Mike Schuchardt2d523e52022-09-15 12:25:58 -07005604 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_EXT and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
ziga-lunarg0cf85212021-07-19 01:26:17 +02005605 }
Petr Krausc8655be2017-09-27 18:56:51 +02005606 }
5607
5608 return skip;
5609}
5610
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005611bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005612 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005613 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005614
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005615 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005616 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005617 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
5618 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5619 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005620 }
5621
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005622 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005623 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005624 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
5625 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5626 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005627 }
5628
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005629 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005630 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005631 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
5632 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5633 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005634 }
5635
5636 return skip;
5637}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005638
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005639bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005640 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07005641 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07005642
sjfricke91d9bda2022-08-01 21:44:17 +09005643 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005644 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
sjfricke91d9bda2022-08-01 21:44:17 +09005645 "vkCmdDispatchIndirect(): offset (%" PRIxLEAST64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005646 }
5647 return skip;
5648}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005649
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005650bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5651 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005652 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005653 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005654
5655 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005656 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005657 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005658 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5659 "vkCmdDispatch(): baseGroupX (%" PRIu32
5660 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5661 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005662 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005663 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5664 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5665 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5666 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005667 }
5668
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005669 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005670 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005671 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5672 "vkCmdDispatch(): baseGroupY (%" PRIu32
5673 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5674 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005675 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005676 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5677 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5678 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5679 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005680 }
5681
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005682 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005683 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005684 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5685 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5686 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5687 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005688 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005689 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5690 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5691 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5692 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005693 }
5694
5695 return skip;
5696}
5697
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005698bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5699 VkPipelineBindPoint pipelineBindPoint,
5700 VkPipelineLayout layout, uint32_t set,
5701 uint32_t descriptorWriteCount,
5702 const VkWriteDescriptorSet *pDescriptorWrites) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08005703 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, true);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005704}
5705
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005706bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5707 uint32_t firstExclusiveScissor,
5708 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005709 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005710 bool skip = false;
5711
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005712 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005713 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005714 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005715 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5716 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5717 ") is not 0.",
5718 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005719 }
5720 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005721 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005722 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5723 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5724 ") is not 1.",
5725 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005726 }
5727 } else { // multiViewport enabled
5728 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005729 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005730 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5731 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5732 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5733 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005734 }
5735 }
5736
Jeff Bolz3e71f782018-08-29 23:15:45 -05005737 if (pExclusiveScissors) {
5738 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5739 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5740
5741 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005742 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5743 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5744 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005745 }
5746
5747 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005748 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5749 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5750 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005751 }
5752
5753 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5754 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005755 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5756 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5757 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5758 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005759 }
5760
5761 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5762 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005763 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5764 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5765 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5766 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005767 }
5768 }
5769 }
5770
5771 return skip;
5772}
5773
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005774bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5775 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005776 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005777 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005778 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5779 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5780 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5781 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5782 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5783 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005784 }
5785
5786 return skip;
5787}
5788
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005789bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5790 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005791 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005792 bool skip = false;
5793
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005794 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005795 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005796 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005797 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5798 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5799 ") is not 0.",
5800 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005801 }
5802 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005803 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005804 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5805 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5806 ") is not 1.",
5807 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005808 }
5809 }
5810
Jeff Bolz9af91c52018-09-01 21:53:57 -05005811 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005812 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005813 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5814 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5815 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5816 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005817 }
5818
5819 return skip;
5820}
5821
Jeff Bolz5c801d12019-10-09 10:38:45 -05005822bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5823 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5824 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005825 bool skip = false;
5826
Dave Houlton142c4cb2018-10-17 15:04:41 -06005827 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005828 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5829 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5830 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005831 }
5832
5833 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005834 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005835 }
5836
5837 return skip;
5838}
5839
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005840bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005841 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005842 bool skip = false;
5843
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005844 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005845 skip |= LogError(
5846 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005847 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5848 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005849 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005850 }
5851
5852 return skip;
5853}
5854
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005855bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5856 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005857 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005858 bool skip = false;
sjfricke91d9bda2022-08-01 21:44:17 +09005859 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005860 skip |= LogError(
5861 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005862 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005863 }
sjfricke91d9bda2022-08-01 21:44:17 +09005864 if (drawCount > 1 && ((stride & 3) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005865 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5866 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5867 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5868 stride);
Lockee1c22882019-06-10 16:02:54 -06005869 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005870 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005871 skip |= LogError(
5872 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005873 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5874 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005875 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005876 if (drawCount > device_limits.maxDrawIndirectCount) {
5877 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005878 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5879 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005880 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005881 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005882 return skip;
5883}
5884
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005885bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5886 VkDeviceSize offset, VkBuffer countBuffer,
5887 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005888 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005889 bool skip = false;
5890
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005891 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005892 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5893 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5894 "), is not a multiple of 4.",
5895 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005896 }
5897
5898 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005899 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5900 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5901 "), is not a multiple of 4.",
5902 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005903 }
5904
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005905 return skip;
5906}
5907
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005908bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005909 const VkAllocationCallbacks *pAllocator,
5910 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005911 bool skip = false;
5912
5913 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5914 if (pCreateInfo != nullptr) {
5915 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5916 // VkQueryPipelineStatisticFlagBits values
5917 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5918 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005919 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5920 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5921 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5922 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005923 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005924 if (pCreateInfo->queryCount == 0) {
5925 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5926 "vkCreateQueryPool(): queryCount must be greater than zero.");
5927 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005928 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005929 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005930}
5931
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005932bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5933 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005934 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005935 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5936 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005937}
5938
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005939void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005940 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5941 VkResult result) {
5942 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005943 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005944}
5945
Mike Schuchardt2df08912020-12-15 16:28:09 -08005946void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005947 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5948 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005949 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005950 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005951 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005952}
5953
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005954void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5955 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005956 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005957 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005958 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005959}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005960
Tony-LunarG3c287f62020-12-17 12:39:49 -07005961void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005962 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005963 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005964 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005965 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005966 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005967 }
5968 }
5969}
5970
5971void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005972 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005973 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005974 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5975 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5976 }
5977}
5978
5979void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005980 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005981 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005982 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5983 if (item->second == commandPool) {
5984 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005985 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005986 ++item;
5987 }
5988 }
5989}
5990
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005991bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005992 const VkAllocationCallbacks *pAllocator,
5993 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005994 bool skip = false;
5995
5996 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005997 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005998 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005999 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
6000 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06006001 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06006002
6003 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006004 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06006005 if (flags_info) {
6006 flags = flags_info->flags;
6007 }
6008
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006009 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06006010 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08006011 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006012 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
6013 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08006014 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06006015 }
6016
6017#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006018 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06006019#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006020 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
6021 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06006022#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006023 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06006024#endif
6025
6026 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006027 skip |= LogError(
6028 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06006029 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
6030 }
6031 if (
6032#ifdef VK_USE_PLATFORM_WIN32_KHR
6033 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
6034#endif
6035 (import_memory_fd && import_memory_fd->handleType) ||
6036#ifdef VK_USE_PLATFORM_ANDROID_KHR
6037 (import_memory_ahb && import_memory_ahb->buffer) ||
6038#endif
6039 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006040 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
6041 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06006042 }
6043 }
6044
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02006045 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
6046 if (export_memory) {
6047 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
6048 if (export_memory_nv) {
6049 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
6050 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
6051 "VkExportMemoryAllocateInfoNV");
6052 }
6053#ifdef VK_USE_PLATFORM_WIN32_KHR
6054 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
6055 if (export_memory_win32_nv) {
6056 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
6057 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
6058 "VkExportMemoryWin32HandleInfoNV");
6059 }
6060#endif
6061 }
6062
Jeff Bolz4563f2a2019-12-10 13:30:30 -06006063 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07006064 VkBool32 capture_replay = false;
6065 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006066 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07006067 if (vulkan_12_features) {
6068 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
6069 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
6070 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006071 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07006072 if (bda_features) {
6073 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
6074 buffer_device_address = bda_features->bufferDeviceAddress;
6075 }
6076 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08006077 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006078 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08006079 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006080 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06006081 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08006082 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006083 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08006084 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06006085 }
6086 }
Tony-LunarG115f89d2022-06-15 10:53:22 -06006087#ifdef VK_USE_PLATFORM_METAL_EXT
6088 skip |= ExportMetalObjectsPNextUtil(
6089 VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT, "VUID-VkMemoryAllocateInfo-pNext-06780",
6090 "vkAllocateMemory():", "VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT", pAllocateInfo->pNext);
6091#endif // VK_USE_PLATFORM_METAL_EXT
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06006092 }
6093 return skip;
6094}
Ricardo Garciaa4935972019-02-21 17:43:18 +01006095
Jason Macnak192fa0e2019-07-26 15:07:16 -07006096bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006097 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07006098 bool skip = false;
6099
6100 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
6101 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
6102 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006103 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006104 } else {
6105 uint32_t vertex_component_size = 0;
6106 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
6107 vertex_component_size = 4;
6108 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
6109 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
6110 vertex_component_size = 2;
6111 }
6112 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006113 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006114 }
6115 }
6116
6117 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6118 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006119 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006120 } else {
6121 uint32_t index_element_size = 0;
6122 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
6123 index_element_size = 4;
6124 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
6125 index_element_size = 2;
6126 }
6127 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006128 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006129 }
6130 }
6131 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
6132 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006133 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006134 }
6135 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006136 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006137 }
6138 }
6139
6140 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006141 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006142 }
6143
6144 return skip;
6145}
6146
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006147bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
6148 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07006149 bool skip = false;
6150
6151 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006152 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006153 }
6154 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006155 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006156 }
6157
6158 return skip;
6159}
6160
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006161bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
6162 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07006163 bool skip = false;
6164 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006165 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006166 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006167 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006168 }
6169 return skip;
6170}
6171
6172bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07006173 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06006174 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006175 bool skip = false;
6176 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006177 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
6178 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
6179 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07006180 }
6181 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006182 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
6183 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
6184 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07006185 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02006186 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6187 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
6188 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
6189 }
Jason Macnak5c954952019-07-09 15:46:12 -07006190 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
6191 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006192 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
6193 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
6194 "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 -07006195 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006196 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006197 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06006198 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
6199 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006200 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
6201 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07006202 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006203 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006204 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
6205 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
6206 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07006207 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07006208 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07006209 uint64_t total_triangle_count = 0;
6210 for (uint32_t i = 0; i < info.geometryCount; i++) {
6211 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07006212
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006213 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006214
Jason Macnak5c954952019-07-09 15:46:12 -07006215 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
6216 continue;
6217 }
6218 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
6219 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006220 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006221 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
6222 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
6223 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07006224 }
6225 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07006226 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
6227 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
6228 for (uint32_t i = 1; i < info.geometryCount; i++) {
6229 const VkGeometryNV &geometry = info.pGeometries[i];
6230 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006231 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006232 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
6233 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006234 "info.pGeometries[0].geometryType.",
6235 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07006236 }
6237 }
6238 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006239 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
6240 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
6241 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
6242 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
6243 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
6244 "or VK_GEOMETRY_TYPE_AABBS_NV.");
6245 }
6246 }
6247 skip |=
6248 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06006249 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07006250 return skip;
6251}
6252
Ricardo Garciaa4935972019-02-21 17:43:18 +01006253bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
6254 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006255 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01006256 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01006257 if (pCreateInfo) {
6258 if ((pCreateInfo->compactedSize != 0) &&
6259 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006260 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
6261 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
6262 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
6263 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01006264 }
Jason Macnak5c954952019-07-09 15:46:12 -07006265
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006266 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07006267 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01006268 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01006269 return skip;
6270}
Mike Schuchardt21638df2019-03-16 10:52:02 -07006271
Jeff Bolz5c801d12019-10-09 10:38:45 -05006272bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
6273 const VkAccelerationStructureInfoNV *pInfo,
6274 VkBuffer instanceData, VkDeviceSize instanceOffset,
6275 VkBool32 update, VkAccelerationStructureNV dst,
6276 VkAccelerationStructureNV src, VkBuffer scratch,
6277 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006278 bool skip = false;
6279
6280 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006281 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07006282 }
6283
6284 return skip;
6285}
6286
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006287bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
6288 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6289 VkAccelerationStructureKHR *pAccelerationStructure) const {
6290 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006291 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006292 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006293 if (!acceleration_structure_features ||
6294 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
6295 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
6296 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
6297 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006298 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006299 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
6300 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006301 (acceleration_structure_features &&
6302 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07006303 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07006304 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
6305 "vkCreateAccelerationStructureKHR(): If createFlags includes "
6306 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
6307 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07006308 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006309 if (pCreateInfo->deviceAddress &&
6310 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
6311 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
6312 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
6313 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
6314 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006315 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
6316 (acceleration_structure_features &&
6317 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
6318 skip |= LogError(
6319 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
6320 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
6321 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
6322 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006323 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
6324 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006325 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
6326 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07006327 }
sourav parmar83c31b12020-05-06 12:30:54 -07006328 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006329 return skip;
6330}
6331
Jason Macnak5c954952019-07-09 15:46:12 -07006332bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
6333 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006334 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006335 bool skip = false;
6336 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006337 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
6338 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07006339 }
6340 return skip;
6341}
6342
sourav parmarcd5fb182020-07-17 12:58:44 -07006343bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
6344 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
6345 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6346 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006347 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07006348 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07006349 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006350 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006351 }
6352 return skip;
6353}
6354
Peter Chen85366392019-05-14 15:20:11 -04006355bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
6356 uint32_t createInfoCount,
6357 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
6358 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006359 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04006360 bool skip = false;
6361
6362 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006363 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6364 std::stringstream msg;
6365 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6366 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
6367 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006368 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04006369 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06006370 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineStageCreationFeedbackCount-06651",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006371 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
6372 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
6373 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
6374 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04006375 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006376
ziga-lunarg22589cf2022-09-16 19:58:56 +02006377 const auto *vulkan_13_features = LvlFindInChain<VkPhysicalDeviceVulkan13Features>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006378 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006379 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
ziga-lunarg22589cf2022-09-16 19:58:56 +02006380 if ((!vulkan_13_features || vulkan_13_features->pipelineCreationCacheControl == VK_FALSE) &&
6381 (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE)) {
sourav parmara96ab1a2020-04-25 16:28:23 -07006382 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6383 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6384 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
6385 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
6386 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6387 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6388 }
6389 }
6390
sourav parmarf4a78252020-04-10 13:04:21 -07006391 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
6392 skip |=
6393 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
6394 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
6395 }
6396 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
6397 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
6398 skip |=
6399 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
6400 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
6401 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
6402 }
6403 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6404 if (pCreateInfos[i].basePipelineIndex != -1) {
6405 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6406 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
6407 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
6408 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6409 "and pCreateInfos->basePipelineIndex is not -1.");
6410 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006411 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006412 skip |=
6413 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
6414 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
6415 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
6416 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
6417 "that element.");
6418 }
sourav parmarf4a78252020-04-10 13:04:21 -07006419 }
6420 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006421 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006422 skip |=
6423 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
6424 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6425 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
6426 "commands pCreateInfos parameter.");
6427 }
6428 } else {
6429 if (pCreateInfos[i].basePipelineIndex != -1) {
6430 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
6431 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6432 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6433 }
6434 }
6435 }
6436 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
6437 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
6438 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
6439 }
6440 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
6441 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
6442 "vkCreateRayTracingPipelinesNV: flags must not include "
6443 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
6444 }
6445 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
6446 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
6447 "vkCreateRayTracingPipelinesNV: flags must not include "
6448 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
6449 }
6450 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
6451 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
6452 "vkCreateRayTracingPipelinesNV: flags must not include "
6453 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
6454 }
6455 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
6456 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
6457 "vkCreateRayTracingPipelinesNV: flags must not include "
6458 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
6459 }
6460 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6461 skip |= LogError(
6462 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
6463 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6464 }
6465 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6466 skip |= LogError(
6467 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
6468 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
6469 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006470 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
6471 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
6472 "vkCreateRayTracingPipelinesNV: flags must not include "
6473 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6474 }
6475 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6476 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
6477 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
6478 }
ziga-lunargdfffee42021-10-10 11:49:59 +02006479 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
6480 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
6481 "vkCreateRayTracingPipelinesNV: flags must not contain the "
6482 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
6483 }
Peter Chen85366392019-05-14 15:20:11 -04006484 }
6485
6486 return skip;
6487}
6488
sourav parmarcd5fb182020-07-17 12:58:44 -07006489bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
6490 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
6491 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006492 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006493 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006494 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
6495 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
6496 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006497 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006498 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006499 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6500 std::stringstream msg;
6501 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6502 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
aitor-lunargdbd9e652022-02-23 19:12:53 +01006503 &pCreateInfos[i].pStages[stage_index]);
ziga-lunargc6341372021-07-28 12:57:42 +02006504 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006505 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
6506 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6507 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
6508 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6509 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6510 }
6511 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6512 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
6513 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6514 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
6515 }
6516 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006517 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006518 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06006519 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineStageCreationFeedbackCount-06652",
sourav parmarcd5fb182020-07-17 12:58:44 -07006520 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
6521 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
6522 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006523 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
6524 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
6525 }
ziga-lunarg22589cf2022-09-16 19:58:56 +02006526 const auto *vulkan_13_features = LvlFindInChain<VkPhysicalDeviceVulkan13Features>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006527 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006528 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
ziga-lunarg22589cf2022-09-16 19:58:56 +02006529 if ((!vulkan_13_features || vulkan_13_features->pipelineCreationCacheControl == VK_FALSE) &&
6530 (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE)) {
sourav parmara96ab1a2020-04-25 16:28:23 -07006531 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6532 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6533 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07006534 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07006535 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6536 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6537 }
6538 }
sourav parmarf4a78252020-04-10 13:04:21 -07006539 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006540 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
6541 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07006542 }
6543 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006544 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07006545 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07006546 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
6547 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006548 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006549 }
6550 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6551 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
6552 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07006553 }
6554 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
6555 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
6556 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
6557 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
6558 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
6559 skip |= LogError(
6560 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07006561 "vkCreateRayTracingPipelinesKHR: If flags includes "
6562 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006563 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6564 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
6565 "must not be VK_SHADER_UNUSED_KHR");
6566 }
6567 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
6568 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
6569 skip |= LogError(
6570 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07006571 "vkCreateRayTracingPipelinesKHR: If flags includes "
6572 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006573 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6574 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
6575 "element must not be VK_SHADER_UNUSED_KHR");
6576 }
6577 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006578 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
6579 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
6580 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
6581 skip |= LogError(
6582 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
6583 "vkCreateRayTracingPipelinesKHR: If "
6584 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
6585 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
6586 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6587 }
6588 }
sourav parmarf4a78252020-04-10 13:04:21 -07006589 }
6590 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6591 if (pCreateInfos[i].basePipelineIndex != -1) {
6592 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6593 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07006594 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07006595 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6596 "and pCreateInfos->basePipelineIndex is not -1.");
6597 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006598 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006599 skip |=
6600 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
6601 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
6602 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
6603 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
6604 "element.");
6605 }
sourav parmarf4a78252020-04-10 13:04:21 -07006606 }
6607 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006608 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006609 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07006610 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006611 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
6612 ") must be a valid into the calling"
6613 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07006614 pCreateInfos[i].basePipelineIndex, createInfoCount);
6615 }
6616 } else {
6617 if (pCreateInfos[i].basePipelineIndex != -1) {
6618 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07006619 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07006620 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6621 }
6622 }
6623 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006624 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
6625 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
6626 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
6627 "vkCreateRayTracingPipelinesKHR: If flags includes "
6628 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
6629 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006630 }
6631 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
6632 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
6633 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
6634 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
6635 "pLibraryInfo and pLibraryInterface must be NULL.");
6636 }
6637 if (pCreateInfos[i].pLibraryInfo) {
6638 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
6639 if (pCreateInfos[i].stageCount == 0) {
6640 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
6641 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6642 "stageCount must not be 0.");
6643 }
6644 if (pCreateInfos[i].groupCount == 0) {
6645 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
6646 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6647 "groupCount must not be 0.");
6648 }
6649 } else {
6650 if (pCreateInfos[i].pLibraryInterface == NULL) {
6651 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
6652 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6653 "is greater than 0, its "
6654 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006655 }
6656 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006657 }
6658 if (pCreateInfos[i].pLibraryInterface) {
6659 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6660 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6661 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6662 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6663 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6664 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006665 }
6666 if (deferredOperation != VK_NULL_HANDLE) {
6667 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6668 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6669 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6670 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006671 }
6672 }
ziga-lunargdea76582021-09-17 14:38:08 +02006673 if (pCreateInfos[i].pDynamicState) {
6674 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6675 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6676 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6677 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6678 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6679 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6680 }
6681 }
6682 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006683 }
6684
6685 return skip;
6686}
6687
Mike Schuchardt21638df2019-03-16 10:52:02 -07006688#ifdef VK_USE_PLATFORM_WIN32_KHR
6689bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6690 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006691 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006692 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006693 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006694 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006695 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006696 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006697 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006698 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006699 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006700 skip |=
6701 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006702 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006703 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6704 skip |= validate_struct_type(
6705 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6706 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6707 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6708 if (pSurfaceInfo != NULL) {
6709 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6710 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6711 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6712
6713 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6714 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6715 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6716 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006717 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6718 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006719
Mike Schuchardt05b028d2022-01-05 14:15:00 -08006720 if (pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
6721 skip |= LogError(device, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
6722 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
6723 "VK_GOOGLE_surfaceless_query is not enabled.");
6724 }
6725
Mike Schuchardt21638df2019-03-16 10:52:02 -07006726 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6727 }
6728 return skip;
6729}
6730#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006731
6732bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6733 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006734 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006735 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6736 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006737 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006738 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6739 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6740 }
6741 return skip;
6742}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006743
6744bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006745 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006746 bool skip = false;
6747
6748 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006749 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006750 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006751 }
6752
6753 return skip;
6754}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006755
6756bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006757 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006758 bool skip = false;
6759
6760 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006761 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6762 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006763 }
6764
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006765 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006766 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006767 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6768 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006769 }
6770
6771 return skip;
6772}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006773
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006774bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6775 uint32_t bindingCount, const VkBuffer *pBuffers,
6776 const VkDeviceSize *pOffsets) const {
6777 bool skip = false;
6778 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006779 skip |=
6780 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6781 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6782 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006783 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6784 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006785 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6786 ") must be less than "
6787 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006788 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6789 }
6790
Jeff Bolz165818a2020-05-08 11:19:03 -05006791 for (uint32_t i = 0; i < bindingCount; ++i) {
6792 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006793 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006794 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006795 skip |=
6796 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6797 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006798 } else {
6799 if (pOffsets[i] != 0) {
6800 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006801 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6802 "] is not 0",
6803 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006804 }
6805 }
6806 }
6807 }
6808
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006809 return skip;
6810}
6811
Mark Lobodzinski84988402019-09-11 15:27:30 -06006812bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006813 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006814 bool skip = false;
6815 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006816 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6817 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006818 }
6819 return skip;
6820}
6821
6822bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006823 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006824 bool skip = false;
6825 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006826 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6827 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006828 }
6829 return skip;
6830}
Petr Kraus3d720392019-11-13 02:52:39 +01006831
6832bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6833 VkSemaphore semaphore, VkFence fence,
6834 uint32_t *pImageIndex) const {
6835 bool skip = false;
6836
6837 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006838 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6839 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006840 }
6841
6842 return skip;
6843}
6844
6845bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6846 uint32_t *pImageIndex) const {
6847 bool skip = false;
6848
6849 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006850 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6851 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006852 }
6853
6854 return skip;
6855}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006856
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006857bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6858 uint32_t firstBinding, uint32_t bindingCount,
6859 const VkBuffer *pBuffers,
6860 const VkDeviceSize *pOffsets,
6861 const VkDeviceSize *pSizes) const {
6862 bool skip = false;
6863
6864 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6865 for (uint32_t i = 0; i < bindingCount; ++i) {
6866 if (pOffsets[i] & 3) {
6867 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6868 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6869 }
6870 }
6871
6872 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6873 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6874 "%s: The firstBinding(%" PRIu32
6875 ") index is greater than or equal to "
6876 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6877 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6878 }
6879
6880 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6881 skip |=
6882 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6883 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6884 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6885 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6886 }
6887
6888 for (uint32_t i = 0; i < bindingCount; ++i) {
6889 // pSizes is optional and may be nullptr.
6890 if (pSizes != nullptr) {
6891 if (pSizes[i] != VK_WHOLE_SIZE &&
6892 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6893 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6894 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6895 ") is not VK_WHOLE_SIZE and is greater than "
6896 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6897 cmd_name, i, pSizes[i]);
6898 }
6899 }
6900 }
6901
6902 return skip;
6903}
6904
6905bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6906 uint32_t firstCounterBuffer,
6907 uint32_t counterBufferCount,
6908 const VkBuffer *pCounterBuffers,
6909 const VkDeviceSize *pCounterBufferOffsets) const {
6910 bool skip = false;
6911
6912 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6913 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6914 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6915 "%s: The firstCounterBuffer(%" PRIu32
6916 ") index is greater than or equal to "
6917 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6918 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6919 }
6920
6921 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6922 skip |=
6923 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6924 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6925 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6926 cmd_name, firstCounterBuffer, counterBufferCount,
6927 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6928 }
6929
6930 return skip;
6931}
6932
6933bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6934 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6935 const VkBuffer *pCounterBuffers,
6936 const VkDeviceSize *pCounterBufferOffsets) const {
6937 bool skip = false;
6938
6939 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6940 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6941 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6942 "%s: The firstCounterBuffer(%" PRIu32
6943 ") index is greater than or equal to "
6944 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6945 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6946 }
6947
6948 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6949 skip |=
6950 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6951 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6952 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6953 cmd_name, firstCounterBuffer, counterBufferCount,
6954 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6955 }
6956
6957 return skip;
6958}
6959
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006960bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6961 uint32_t firstInstance, VkBuffer counterBuffer,
6962 VkDeviceSize counterBufferOffset,
6963 uint32_t counterOffset, uint32_t vertexStride) const {
6964 bool skip = false;
6965
6966 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006967 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6968 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6969 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6970 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006971 }
6972
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006973 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006974 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006975 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006976 }
6977
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006978 return skip;
6979}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006980
6981bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6982 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6983 const VkAllocationCallbacks *pAllocator,
6984 VkSamplerYcbcrConversion *pYcbcrConversion,
6985 const char *apiName) const {
6986 bool skip = false;
6987
6988 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006989 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006990 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006991 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006992 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6993 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006994 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006995 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006996 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006997
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006998#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006999 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007000 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007001#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007002 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007003#endif
7004
sfricke-samsung1a72f942020-07-25 12:09:18 -07007005 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007006
7007 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007008 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007009 const VkComponentMapping components = pCreateInfo->components;
7010 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
7011 if (FormatIsXChromaSubsampled(format) == true) {
7012 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
7013 skip |=
7014 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07007015 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
7016 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07007017 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007018 }
sfricke-samsung83d98122020-07-04 06:21:15 -07007019
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007020 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
7021 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
7022 skip |= LogError(
7023 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
7024 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
7025 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
7026 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
7027 }
sfricke-samsung83d98122020-07-04 06:21:15 -07007028
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007029 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
7030 (components.r != VK_COMPONENT_SWIZZLE_B)) {
7031 skip |=
7032 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07007033 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
7034 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07007035 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007036 }
sfricke-samsung83d98122020-07-04 06:21:15 -07007037
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007038 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
7039 (components.b != VK_COMPONENT_SWIZZLE_R)) {
7040 skip |=
7041 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07007042 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
7043 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07007044 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007045 }
sfricke-samsung83d98122020-07-04 06:21:15 -07007046
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007047 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007048 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
7049 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
7050 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007051 skip |=
7052 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07007053 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
7054 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07007055 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
7056 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007057 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07007058 }
7059
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007060 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
7061 // Checks same VU multiple ways in order to give a more useful error message
7062 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
7063 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
7064 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
7065 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
7066 skip |= LogError(
7067 device, vuid,
7068 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
7069 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
7070 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
7071 string_VkComponentSwizzle(components.b));
7072 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07007073
sfricke-samsunged028b02021-09-06 23:14:51 -07007074 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
7075 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007076 // 3 = no [a]
7077 // 2 = no [b,a]
7078 // 1 = no [g,b,a]
7079 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07007080 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007081
sfricke-samsunged028b02021-09-06 23:14:51 -07007082 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
7083 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007084 skip |= LogError(device, vuid,
7085 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
7086 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
7087 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
7088 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07007089 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007090 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
7091 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
7092 skip |= LogError(device, vuid,
7093 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
7094 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
7095 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
7096 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
7097 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07007098 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007099 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
7100 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
7101 skip |= LogError(device, vuid,
7102 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
7103 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
7104 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
7105 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
7106 string_VkComponentSwizzle(components.b));
7107 }
sfricke-samsung83d98122020-07-04 06:21:15 -07007108 }
7109 }
7110
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08007111 return skip;
7112}
7113
7114bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
7115 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
7116 const VkAllocationCallbacks *pAllocator,
7117 VkSamplerYcbcrConversion *pYcbcrConversion) const {
7118 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
7119 "vkCreateSamplerYcbcrConversion");
7120}
7121
7122bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
7123 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
7124 VkSamplerYcbcrConversion *pYcbcrConversion) const {
7125 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
7126 "vkCreateSamplerYcbcrConversionKHR");
7127}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08007128
Jeremy Gebben284b68f2022-09-21 15:43:16 -06007129bool StatelessValidation::ValidateExternalSemaphoreHandleType(VkSemaphore semaphore, const char *vuid, const char *caller,
7130 VkExternalSemaphoreHandleTypeFlagBits handle_type,
7131 VkExternalSemaphoreHandleTypeFlags allowed_types) const {
sfricke-samsung1708a8c2020-02-10 00:35:06 -08007132 bool skip = false;
Jeremy Gebben284b68f2022-09-21 15:43:16 -06007133 if (0 == (handle_type & allowed_types)) {
7134 skip |= LogError(semaphore, vuid, "%s(): handleType %s is not one of the supported handleTypes (%s).", caller,
7135 string_VkExternalSemaphoreHandleTypeFlagBits(handle_type),
7136 string_VkExternalSemaphoreHandleTypeFlags(allowed_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08007137 }
7138 return skip;
7139}
sourav parmara96ab1a2020-04-25 16:28:23 -07007140
Jeremy Gebben284b68f2022-09-21 15:43:16 -06007141bool StatelessValidation::ValidateExternalFenceHandleType(VkFence fence, const char *vuid, const char *caller,
7142 VkExternalFenceHandleTypeFlagBits handle_type,
7143 VkExternalFenceHandleTypeFlags allowed_types) const {
7144 bool skip = false;
7145 if (0 == (handle_type & allowed_types)) {
7146 skip |= LogError(fence, vuid, "%s(): handleType %s is not one of the supported handleTypes (%s).", caller,
7147 string_VkExternalFenceHandleTypeFlagBits(handle_type),
7148 string_VkExternalFenceHandleTypeFlags(allowed_types).c_str());
7149 }
7150 return skip;
7151}
7152
7153static constexpr VkExternalSemaphoreHandleTypeFlags kSemFdHandleTypes =
7154 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
7155
7156bool StatelessValidation::manual_PreCallValidateGetSemaphoreFdKHR(VkDevice device, const VkSemaphoreGetFdInfoKHR *info,
7157 int *pFd) const {
7158 return ValidateExternalSemaphoreHandleType(info->semaphore, "VUID-VkSemaphoreGetFdInfoKHR-handleType-01136",
7159 "vkGetSemaphoreFdKHR", info->handleType, kSemFdHandleTypes);
7160}
7161
7162bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(VkDevice device,
7163 const VkImportSemaphoreFdInfoKHR *info) const {
7164 bool skip = false;
7165 const char *func_name = "vkImportSemaphoreFdKHR";
7166
7167 skip |= ValidateExternalSemaphoreHandleType(info->semaphore, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143", func_name,
7168 info->handleType, kSemFdHandleTypes);
7169
7170 if (info->handleType == VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT &&
7171 (info->flags & VK_SEMAPHORE_IMPORT_TEMPORARY_BIT) == 0) {
7172 skip |= LogError(info->semaphore, "VUID-VkImportSemaphoreFdInfoKHR-handleType-07307",
7173 "%s(): handleType is VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT so"
7174 " VK_SEMAPHORE_IMPORT_TEMPORARY_BIT must be set, but flags is 0x%x",
7175 func_name, info->flags);
7176 }
7177 return skip;
7178}
7179
7180static constexpr VkExternalFenceHandleTypeFlags kFenceFdHandleTypes =
7181 VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT;
7182
7183bool StatelessValidation::manual_PreCallValidateGetFenceFdKHR(VkDevice device, const VkFenceGetFdInfoKHR *info, int *pFd) const {
7184 return ValidateExternalFenceHandleType(info->fence, "VUID-VkFenceGetFdInfoKHR-handleType-01456", "vkGetFenceFdKHR",
7185 info->handleType, kFenceFdHandleTypes);
7186}
7187
7188bool StatelessValidation::manual_PreCallValidateImportFenceFdKHR(VkDevice device, const VkImportFenceFdInfoKHR *info) const {
7189 bool skip = false;
7190 const char *func_name = "vkImportFenceFdKHR";
7191
7192 skip |= ValidateExternalFenceHandleType(info->fence, "VUID-VkImportFenceFdInfoKHR-handleType-01464", func_name,
7193 info->handleType, kFenceFdHandleTypes);
7194
7195 if (info->handleType == VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT && (info->flags & VK_FENCE_IMPORT_TEMPORARY_BIT) == 0) {
7196 skip |= LogError(info->fence, "VUID-VkImportFenceFdInfoKHR-handleType-07306",
7197 "%s(): handleType is VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT so"
7198 " VK_FENCE_IMPORT_TEMPORARY_BIT must be set, but flags is 0x%x",
7199 func_name, info->flags);
7200 }
7201 return skip;
7202}
7203
7204#ifdef VK_USE_PLATFORM_WIN32_KHR
7205static constexpr VkExternalSemaphoreHandleTypeFlags kSemWin32HandleTypes =
7206 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT |
7207 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT;
7208
7209bool StatelessValidation::manual_PreCallValidateImportSemaphoreWin32HandleKHR(
7210 VkDevice device, const VkImportSemaphoreWin32HandleInfoKHR *info) const {
7211 bool skip = false;
7212 const char *func_name = "vkImportSemaphoreWin32HandleKHR";
7213
7214 skip |= ValidateExternalSemaphoreHandleType(info->semaphore, "VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-01140",
7215 func_name, info->handleType, kSemWin32HandleTypes);
7216
7217 static constexpr auto kNameAllowedTypes =
7218 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT;
7219 if ((info->handleType & kNameAllowedTypes) == 0 && info->name) {
7220 skip |= LogError(info->semaphore, "VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-01466",
7221 "%s(): name (%p) must be NULL if handleType is %s", func_name, info->name,
7222 string_VkExternalSemaphoreHandleTypeFlagBits(info->handleType));
7223 }
7224 if (info->handle && info->name) {
7225 skip |= LogError(info->semaphore, "VUID-VkImportSemaphoreWin32HandleInfoKHR-handle-01469",
7226 "%s(): both handle (%p) and name (%p) are non-NULL", func_name, info->handle, info->name);
7227 }
7228 return skip;
7229}
7230
7231bool StatelessValidation::manual_PreCallValidateGetSemaphoreWin32HandleKHR(VkDevice device,
7232 const VkSemaphoreGetWin32HandleInfoKHR *info,
7233 HANDLE *pHandle) const {
7234 return ValidateExternalSemaphoreHandleType(info->semaphore, "VUID-VkSemaphoreGetWin32HandleInfoKHR-handleType-01131",
7235 "vkGetSemaphoreWin32HandleKHR", info->handleType, kSemWin32HandleTypes);
7236}
7237
7238static constexpr VkExternalFenceHandleTypeFlags kFenceWin32HandleTypes =
7239 VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT | VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT;
7240
7241bool StatelessValidation::manual_PreCallValidateImportFenceWin32HandleKHR(VkDevice device,
7242 const VkImportFenceWin32HandleInfoKHR *info) const {
7243 bool skip = false;
7244 const char *func_name = "vkImportFenceWin32HandleKHR";
7245
7246 skip |= ValidateExternalFenceHandleType(info->fence, func_name, "VUID-VkImportFenceWin32HandleInfoKHR-handleType-01457",
7247 info->handleType, kFenceWin32HandleTypes);
7248
7249 static constexpr auto kNameAllowedTypes = VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT;
7250 if ((info->handleType & kNameAllowedTypes) == 0 && info->name) {
7251 skip |= LogError(info->fence, "VUID-VkImportFenceWin32HandleInfoKHR-handleType-01459",
7252 "%s(): name (%p) must be NULL if handleType is %s", func_name, info->name,
7253 string_VkExternalFenceHandleTypeFlagBits(info->handleType));
7254 }
7255 if (info->handle && info->name) {
7256 skip |= LogError(info->fence, "VUID-VkImportFenceWin32HandleInfoKHR-handle-01462",
7257 "%s(): both handle (%p) and name (%p) are non-NULL", func_name, info->handle, info->name);
7258 }
7259 return skip;
7260}
7261
7262bool StatelessValidation::manual_PreCallValidateGetFenceWin32HandleKHR(VkDevice device, const VkFenceGetWin32HandleInfoKHR *info,
7263 HANDLE *pHandle) const {
7264 return ValidateExternalFenceHandleType(info->fence, "vkGetFenceWin32HandleKHR",
7265 "VUID-VkFenceGetWin32HandleInfoKHR-handleType-01452", info->handleType,
7266 kFenceWin32HandleTypes);
7267}
7268#endif
7269
sourav parmara96ab1a2020-04-25 16:28:23 -07007270bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007271 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07007272 bool skip = false;
7273 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
7274 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
7275 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
7276 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007277 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007278 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
7279 skip |= LogError(
7280 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
7281 "vkCopyAccelerationStructureToMemoryKHR: The "
7282 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
7283 }
7284 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
7285 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
7286 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
7287 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
7288 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
7289 }
sourav parmara96ab1a2020-04-25 16:28:23 -07007290 return skip;
7291}
7292
7293bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
7294 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
7295 bool skip = false;
7296 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
7297 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
7298 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
7299 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
7300 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007301 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
7302 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007303 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07007304 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07007305 }
sourav parmara96ab1a2020-04-25 16:28:23 -07007306 return skip;
7307}
7308
7309bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
7310 const char *api_name) const {
7311 bool skip = false;
7312 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
7313 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
7314 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
7315 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
7316 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
7317 api_name);
7318 }
7319 return skip;
7320}
7321
7322bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007323 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07007324 bool skip = false;
7325 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007326 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007327 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07007328 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07007329 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
7330 "vkCopyAccelerationStructureKHR: The "
7331 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007332 }
sourav parmara96ab1a2020-04-25 16:28:23 -07007333 return skip;
7334}
7335
7336bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
7337 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
7338 bool skip = false;
7339 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
7340 return skip;
7341}
7342
7343bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06007344 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07007345 bool skip = false;
7346 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007347 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07007348 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
7349 }
7350 return skip;
7351}
7352
7353bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007354 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07007355 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07007356 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007357 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007358 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
7359 skip |= LogError(
7360 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
7361 "vkCopyMemoryToAccelerationStructureKHR: The "
7362 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007363 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007364 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
7365 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07007366 return skip;
7367}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06007368
sourav parmara96ab1a2020-04-25 16:28:23 -07007369bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
7370 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
7371 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07007372 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07007373 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
7374 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007375 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07007376 pInfo->src.deviceAddress);
7377 }
sourav parmar83c31b12020-05-06 12:30:54 -07007378 return skip;
7379}
7380bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
7381 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
7382 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
7383 bool skip = false;
7384 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
7385 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
sfricke-samsungf91881c2022-03-31 01:12:00 -05007386 if (!IsExtEnabled(device_extensions.vk_khr_ray_tracing_maintenance1)) {
7387 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
7388 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7389 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7390 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7391 } else if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR ||
7392 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR)) {
7393 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-06742",
7394 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7395 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR or "
7396 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR or "
7397 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7398 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7399 }
sourav parmar83c31b12020-05-06 12:30:54 -07007400 }
7401 return skip;
7402}
7403bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
7404 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
7405 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
7406 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007407 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007408 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7409 skip |= LogError(
7410 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
7411 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
7412 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
7413 }
sourav parmar83c31b12020-05-06 12:30:54 -07007414 if (dataSize < accelerationStructureCount * stride) {
7415 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
7416 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007417 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07007418 dataSize, accelerationStructureCount, stride);
7419 }
sfricke-samsungf91881c2022-03-31 01:12:00 -05007420
sourav parmar83c31b12020-05-06 12:30:54 -07007421 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
7422 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
sfricke-samsungf91881c2022-03-31 01:12:00 -05007423 if (!IsExtEnabled(device_extensions.vk_khr_ray_tracing_maintenance1)) {
7424 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
7425 "vkWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7426 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7427 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7428 } else if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR ||
7429 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR)) {
7430 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06742",
7431 "vkWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7432 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR or "
7433 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR or "
7434 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7435 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7436 }
sourav parmar83c31b12020-05-06 12:30:54 -07007437 }
sfricke-samsungf91881c2022-03-31 01:12:00 -05007438
7439 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
7440 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07007441 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
7442 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7443 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
7444 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7445 stride);
sfricke-samsungf91881c2022-03-31 01:12:00 -05007446 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07007447 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
7448 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7449 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
7450 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7451 stride);
sfricke-samsungf91881c2022-03-31 01:12:00 -05007452 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR) {
7453 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06731",
7454 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7455 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR,"
7456 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7457 stride);
7458 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR) {
7459 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06733",
7460 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7461 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR,"
7462 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7463 stride);
sourav parmar83c31b12020-05-06 12:30:54 -07007464 }
7465 }
sourav parmar83c31b12020-05-06 12:30:54 -07007466 return skip;
7467}
7468bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
7469 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
7470 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007471 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007472 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
7473 skip |= LogError(
7474 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
7475 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
7476 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07007477 }
7478 return skip;
7479}
7480
7481bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07007482 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7483 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
7484 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7485 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07007486 uint32_t width, uint32_t height, uint32_t depth) const {
7487 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07007488 // RayGen
7489 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7490 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
7491 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007492 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007493 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7494 0) {
7495 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
7496 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7497 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7498 }
7499 // Callable
7500 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7501 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
7502 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7503 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007504 }
7505 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7506 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
7507 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007508 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7509 }
7510 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7511 0) {
7512 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
7513 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7514 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007515 }
7516 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007517 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7518 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
7519 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7520 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007521 }
7522 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7523 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007524 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
7525 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07007526 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007527 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7528 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
7529 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7530 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7531 }
sourav parmar83c31b12020-05-06 12:30:54 -07007532 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007533 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7534 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
7535 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
7536 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07007537 }
7538 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7539 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
7540 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007541 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7542 }
7543 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7544 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
7545 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7546 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7547 }
7548 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
Mike Schuchardt840f1252022-05-11 11:31:25 -07007549 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03641",
sourav parmarcd5fb182020-07-17 12:58:44 -07007550 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
7551 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
7552 }
7553 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
7554 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007555 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03638",
sourav parmarcd5fb182020-07-17 12:58:44 -07007556 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
7557 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07007558 }
7559
sourav parmarcd5fb182020-07-17 12:58:44 -07007560 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
7561 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007562 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03639",
sourav parmarcd5fb182020-07-17 12:58:44 -07007563 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
7564 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
7565 }
7566
7567 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
7568 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007569 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03640",
sourav parmarcd5fb182020-07-17 12:58:44 -07007570 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
7571 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07007572 }
7573 return skip;
7574}
7575
sourav parmarcd5fb182020-07-17 12:58:44 -07007576bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
7577 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7578 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7579 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007580 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007581 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007582 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7583 skip |= LogError(
7584 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
7585 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7586 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007587 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007588 // RayGen
7589 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7590 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
7591 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007592 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007593 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7594 0) {
7595 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
7596 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7597 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7598 }
7599 // Callabe
7600 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7601 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
7602 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7603 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007604 }
7605 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7606 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07007607 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
7608 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7609 }
7610 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7611 0) {
7612 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
7613 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7614 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007615 }
7616 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007617 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7618 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
7619 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7620 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007621 }
7622 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7623 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007624 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
7625 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07007626 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007627 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7628 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
7629 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7630 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7631 }
sourav parmar83c31b12020-05-06 12:30:54 -07007632 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007633 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7634 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
7635 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
7636 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007637 }
7638 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7639 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07007640 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
7641 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7642 }
7643 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7644 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
7645 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7646 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007647 }
7648
sourav parmarcd5fb182020-07-17 12:58:44 -07007649 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7650 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
7651 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07007652 }
7653 return skip;
7654}
sfricke-samsungf91881c2022-03-31 01:12:00 -05007655
7656bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirect2KHR(VkCommandBuffer commandBuffer,
7657 VkDeviceAddress indirectDeviceAddress) const {
7658 bool skip = false;
7659 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7660 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7661 skip |= LogError(
Mike Schuchardtac73fbe2022-05-24 10:37:52 -07007662 device, "VUID-vkCmdTraceRaysIndirect2KHR-rayTracingPipelineTraceRaysIndirect2-03637",
sfricke-samsungf91881c2022-03-31 01:12:00 -05007663 "vkCmdTraceRaysIndirect2KHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7664 "feature must be enabled.");
7665 }
7666
7667 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7668 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirect2KHR-indirectDeviceAddress-03634",
7669 "vkCmdTraceRaysIndirect2KHR: indirectDeviceAddress must be a multiple of 4.");
7670 }
7671 return skip;
7672}
7673
sourav parmar83c31b12020-05-06 12:30:54 -07007674bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
7675 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
7676 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
7677 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
7678 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
7679 uint32_t width, uint32_t height, uint32_t depth) const {
7680 bool skip = false;
7681 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7682 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
7683 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
7684 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7685 }
7686 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7687 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
7688 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
7689 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7690 }
7691 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7692 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
7693 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
7694 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
7695 }
7696
7697 // hitShader
7698 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7699 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
7700 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
7701 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7702 }
7703 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7704 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
7705 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
7706 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7707 }
7708 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7709 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
7710 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
7711 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7712 }
7713
7714 // missShader
7715 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7716 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
7717 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
7718 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7719 }
7720 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7721 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
7722 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
7723 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7724 }
7725 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7726 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
7727 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
7728 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7729 }
7730
7731 // raygenShader
7732 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7733 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
7734 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07007735 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7736 }
7737 if (width > device_limits.maxComputeWorkGroupCount[0]) {
7738 skip |=
7739 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
7740 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
7741 }
7742 if (height > device_limits.maxComputeWorkGroupCount[1]) {
7743 skip |=
7744 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
7745 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
7746 }
7747 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
7748 skip |=
7749 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
7750 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07007751 }
7752 return skip;
7753}
7754
sourav parmar83c31b12020-05-06 12:30:54 -07007755bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007756 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
7757 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007758 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007759 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
7760 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007761 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
7762 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007763 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07007764 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
7765 }
7766 return skip;
7767}
7768
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007769bool StatelessValidation::ValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7770 const VkViewport *pViewports, bool is_ext) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007771 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007772 const char *api_call = is_ext ? "vkCmdSetViewportWithCountEXT" : "vkCmdSetViewportWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007773
7774 if (!physical_device_features.multiViewport) {
7775 if (viewportCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007776 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03395",
7777 "%s: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", api_call,
Piers Daniell39842ee2020-07-10 16:42:33 -06007778 viewportCount);
7779 }
7780 } else { // multiViewport enabled
7781 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007782 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03394",
7783 "%s: viewportCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007784 ") must "
7785 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007786 api_call, viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007787 }
7788 }
7789
7790 if (pViewports) {
7791 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
7792 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Piers Daniell39842ee2020-07-10 16:42:33 -06007793 skip |= manual_PreCallValidateViewport(
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007794 viewport, api_call, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Piers Daniell39842ee2020-07-10 16:42:33 -06007795 }
7796 }
7797
7798 return skip;
7799}
7800
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007801bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7802 const VkViewport *pViewports) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007803 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007804 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, true);
7805 return skip;
7806}
7807
7808bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7809 const VkViewport *pViewports) const {
7810 bool skip = false;
7811 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, false);
7812 return skip;
7813}
7814
7815bool StatelessValidation::ValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7816 const VkRect2D *pScissors, bool is_ext) const {
7817 bool skip = false;
7818 const char *api_call = is_ext ? "vkCmdSetScissorWithCountEXT" : "vkCmdSetScissorWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007819
7820 if (!physical_device_features.multiViewport) {
7821 if (scissorCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007822 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03398",
7823 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007824 ") must "
7825 "be 1 when the multiViewport feature is disabled.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007826 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007827 }
7828 } else { // multiViewport enabled
7829 if (scissorCount == 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007830 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7831 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007832 ") must "
7833 "be great than zero.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007834 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007835 } else if (scissorCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007836 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7837 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007838 ") must "
7839 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007840 api_call, scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007841 }
7842 }
7843
7844 if (pScissors) {
7845 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
7846 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
7847
7848 if (scissor.offset.x < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007849 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", api_call,
7850 scissor_i, scissor.offset.x);
Piers Daniell39842ee2020-07-10 16:42:33 -06007851 }
7852
7853 if (scissor.offset.y < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007854 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", api_call,
7855 scissor_i, scissor.offset.y);
Piers Daniell39842ee2020-07-10 16:42:33 -06007856 }
7857
7858 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7859 if (x_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007860 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03400",
7861 "%s: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7862 "] will overflow int32_t.",
7863 api_call, scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007864 }
7865
7866 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7867 if (y_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007868 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03401",
7869 "%s: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7870 "] will overflow int32_t.",
7871 api_call, scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7872 }
7873 }
7874 }
7875
7876 return skip;
7877}
7878
7879bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7880 const VkRect2D *pScissors) const {
7881 bool skip = false;
7882 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, true);
7883 return skip;
7884}
7885
7886bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7887 const VkRect2D *pScissors) const {
7888 bool skip = false;
7889 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, false);
7890 return skip;
7891}
7892
7893bool StatelessValidation::ValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount,
7894 const VkBuffer *pBuffers, const VkDeviceSize *pOffsets,
7895 const VkDeviceSize *pSizes, const VkDeviceSize *pStrides,
7896 bool is_2ext) const {
7897 bool skip = false;
7898 const char *api_call = is_2ext ? "vkCmdBindVertexBuffers2EXT()" : "vkCmdBindVertexBuffers2()";
arno-lunarga759e4b2022-09-05 15:40:30 +02007899
7900 // Check VUID-vkCmdBindVertexBuffers2-bindingCount-arraylength
7901 {
7902 const bool vuidCondition = (pSizes != nullptr) || (pStrides != nullptr);
7903 const bool vuidExpectation = bindingCount > 0;
7904 if (vuidCondition) {
7905 if (!vuidExpectation) {
7906 const char *not_null_msg = "";
7907 if ((pSizes != nullptr) && (pStrides != nullptr))
7908 not_null_msg = "pSizes and pStrides are not NULL";
7909 else if (pSizes != nullptr)
7910 not_null_msg = "pSizes is not NULL";
7911 else
7912 not_null_msg = "pStrides is not NULL";
7913 const char *vuid_breach_msg = "%s: %s, so bindingCount must be greater that 0.";
7914 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-bindingCount-arraylength", vuid_breach_msg, api_call,
7915 not_null_msg);
7916 }
7917 }
7918 }
7919
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007920 if (firstBinding >= device_limits.maxVertexInputBindings) {
7921 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03355",
7922 "%s firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")", api_call,
7923 firstBinding, device_limits.maxVertexInputBindings);
7924 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7925 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03356",
7926 "%s sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7927 ") must be less than "
7928 "maxVertexInputBindings (%" PRIu32 ")",
7929 api_call, firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7930 }
7931
7932 for (uint32_t i = 0; i < bindingCount; ++i) {
7933 if (pBuffers[i] == VK_NULL_HANDLE) {
7934 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
7935 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
7936 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04111",
7937 "%s required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", api_call, i);
7938 } else {
7939 if (pOffsets[i] != 0) {
7940 skip |=
7941 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04112",
7942 "%s pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32 "] is not 0", api_call, i, i);
7943 }
7944 }
7945 }
7946 if (pStrides) {
7947 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
7948 skip |=
7949 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pStrides-03362",
7950 "%s pStrides[%" PRIu32 "] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7951 api_call, i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007952 }
7953 }
7954 }
7955
7956 return skip;
7957}
7958
7959bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7960 uint32_t bindingCount, const VkBuffer *pBuffers,
7961 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7962 const VkDeviceSize *pStrides) const {
7963 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007964 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, true);
7965 return skip;
7966}
Piers Daniell39842ee2020-07-10 16:42:33 -06007967
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007968bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7969 uint32_t bindingCount, const VkBuffer *pBuffers,
7970 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7971 const VkDeviceSize *pStrides) const {
7972 bool skip = false;
7973 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, false);
Piers Daniell39842ee2020-07-10 16:42:33 -06007974 return skip;
7975}
sourav parmarcd5fb182020-07-17 12:58:44 -07007976
7977bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7978 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7979 bool skip = false;
7980 for (uint32_t i = 0; i < infoCount; ++i) {
7981 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7982 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7983 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7984 }
7985 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7986 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7987 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7988 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7989 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7990 api_name);
7991 }
7992 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7993 skip |=
7994 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7995 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7996 }
7997 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7998 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7999 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
8000 }
8001 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
8002 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
8003 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
8004 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
8005 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
8006 api_name);
8007 }
8008 if (pInfos[i].pGeometries) {
8009 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
8010 skip |= validate_ranged_enum(
8011 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
8012 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
8013 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
8014 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008015 skip |= validate_struct_type(
8016 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
8017 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
8018 &(pInfos[i].pGeometries[j].geometry.triangles),
8019 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
8020 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
8021 skip |= validate_struct_pnext(
8022 api_name,
8023 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
8024 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
8025 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
8026 skip |=
8027 validate_ranged_enum(api_name,
8028 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
8029 ParameterName::IndexVector{i, j}),
8030 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
8031 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
8032 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
8033 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
8034 &pInfos[i].pGeometries[j].geometry.triangles,
8035 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
8036 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
8037 skip |= validate_ranged_enum(
8038 api_name,
8039 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
8040 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
8041 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
8042
8043 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
8044 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
8045 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
8046 }
8047 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
8048 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
8049 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
8050 skip |=
8051 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
8052 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
8053 api_name);
8054 }
8055 }
8056 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8057 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
8058 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
8059 &pInfos[i].pGeometries[j].geometry.instances,
8060 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
8061 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
8062 skip |= validate_struct_type(
8063 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
8064 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
8065 &(pInfos[i].pGeometries[j].geometry.instances),
8066 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
8067 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
8068 skip |= validate_struct_pnext(
8069 api_name,
8070 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
8071 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
8072 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
8073
8074 skip |= validate_bool32(api_name,
8075 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
8076 ParameterName::IndexVector{i, j}),
8077 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
8078 }
8079 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8080 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
8081 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
8082 &pInfos[i].pGeometries[j].geometry.aabbs,
8083 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
8084 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
8085 skip |= validate_struct_type(
8086 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
8087 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
8088 &(pInfos[i].pGeometries[j].geometry.aabbs),
8089 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
8090 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
8091 skip |= validate_struct_pnext(
8092 api_name,
8093 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
8094 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
8095 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
8096 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
8097 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
8098 "(%s):stride must be less than or equal to 2^32-1", api_name);
8099 }
8100 }
8101 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
8102 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8103 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
8104 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
8105 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
8106 api_name);
8107 }
8108 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
8109 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8110 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
8111 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
8112 "of elements of"
8113 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
8114 api_name);
8115 }
8116 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
8117 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
8118 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
8119 " member of each geometry in either pGeometries or ppGeometries must be the same.",
8120 api_name);
8121 }
8122 }
8123 }
8124 }
8125 if (pInfos[i].ppGeometries != NULL) {
8126 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
8127 skip |= validate_ranged_enum(
8128 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
8129 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
8130 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
8131 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008132 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
8133 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
8134 &pInfos[i].ppGeometries[j]->geometry.triangles,
8135 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
8136 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
8137 skip |= validate_struct_type(
8138 api_name,
8139 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
8140 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
8141 &(pInfos[i].ppGeometries[j]->geometry.triangles),
8142 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
8143 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
8144 skip |= validate_struct_pnext(
8145 api_name,
8146 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
8147 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
8148 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
8149 skip |= validate_ranged_enum(api_name,
8150 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
8151 ParameterName::IndexVector{i, j}),
8152 "VkFormat", AllVkFormatEnums,
8153 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
8154 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
8155 skip |= validate_ranged_enum(api_name,
8156 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
8157 ParameterName::IndexVector{i, j}),
8158 "VkIndexType", AllVkIndexTypeEnums,
8159 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
8160 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
8161 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
8162 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
8163 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
8164 }
8165 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
8166 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
8167 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
8168 skip |=
8169 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
8170 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
8171 api_name);
8172 }
8173 }
8174 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8175 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
8176 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
8177 &pInfos[i].ppGeometries[j]->geometry.instances,
8178 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
8179 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
8180 skip |= validate_struct_type(
8181 api_name,
8182 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
8183 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
8184 &(pInfos[i].ppGeometries[j]->geometry.instances),
8185 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
8186 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
8187 skip |= validate_struct_pnext(
8188 api_name,
8189 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
8190 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
8191 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
8192 skip |= validate_bool32(api_name,
8193 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
8194 ParameterName::IndexVector{i, j}),
8195 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
8196 }
8197 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8198 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
8199 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
8200 &pInfos[i].ppGeometries[j]->geometry.aabbs,
8201 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
8202 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
8203 skip |= validate_struct_type(
8204 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
8205 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
8206 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
8207 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
8208 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
8209 skip |= validate_struct_pnext(
8210 api_name,
8211 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
8212 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
8213 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
8214 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
8215 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
8216 "(%s):stride must be less than or equal to 2^32-1", api_name);
8217 }
8218 }
8219 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
8220 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8221 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
8222 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
8223 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
8224 api_name);
8225 }
8226 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
8227 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8228 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
8229 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
8230 "of elements of"
8231 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
8232 api_name);
8233 }
8234 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
8235 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
8236 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
8237 " member of each geometry in either pGeometries or ppGeometries must be the same.",
8238 api_name);
8239 }
8240 }
8241 }
8242 }
8243 }
8244 return skip;
8245}
8246bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
8247 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
8248 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
8249 bool skip = false;
8250 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
8251 for (uint32_t i = 0; i < infoCount; ++i) {
8252 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
8253 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
8254 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
8255 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
8256 "scratchData.deviceAddress member must be a multiple of "
8257 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
8258 }
8259 for (uint32_t k = 0; k < infoCount; ++k) {
8260 if (i == k) continue;
8261 bool found = false;
8262 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008263 skip |=
8264 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
8265 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
8266 ") of pInfos must "
8267 "not be "
8268 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8269 ") of pInfos.",
8270 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07008271 found = true;
8272 }
8273 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008274 skip |=
8275 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
8276 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
8277 ") of pInfos must "
8278 "not be "
8279 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8280 ") of pInfos.",
8281 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07008282 found = true;
8283 }
8284 if (found) break;
8285 }
8286 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
8287 if (pInfos[i].pGeometries) {
8288 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8289 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
8290 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8291 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
8292 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
8293 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8294 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8295 }
8296 } else {
8297 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
8298 skip |=
8299 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
8300 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
8301 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8302 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8303 }
8304 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01008305 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008306 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8307 skip |= LogError(
8308 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
8309 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
8310 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8311 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01008312 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8313 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008314 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
8315 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
8316 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8317 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8318 }
8319 }
8320 } else if (pInfos[i].ppGeometries) {
8321 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8322 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
8323 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8324 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
8325 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
8326 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8327 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8328 }
8329 } else {
8330 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
8331 skip |=
8332 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
8333 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
8334 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8335 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8336 }
8337 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01008338 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008339 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8340 skip |= LogError(
8341 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
8342 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
8343 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8344 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01008345 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8346 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008347 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
8348 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
8349 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8350 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8351 }
8352 }
8353 }
8354 }
8355 }
8356 return skip;
8357}
8358
8359bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
8360 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
8361 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
8362 const uint32_t *const *ppMaxPrimitiveCounts) const {
8363 bool skip = false;
8364 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
8365 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008366 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07008367 if (!ray_tracing_acceleration_structure_features ||
8368 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
8369 skip |= LogError(
8370 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
8371 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
8372 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
8373 }
8374 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008375 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
8376 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
8377 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
8378 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
8379 "scratchData.deviceAddress member must be a multiple of "
8380 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
8381 }
8382 for (uint32_t k = 0; k < infoCount; ++k) {
8383 if (i == k) continue;
8384 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008385 skip |= LogError(
8386 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
8387 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
8388 ") "
8389 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
8390 "any other element [%" PRIu32 ") of pInfos.",
8391 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07008392 break;
8393 }
8394 }
8395 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
8396 if (pInfos[i].pGeometries) {
8397 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8398 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
8399 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8400 skip |= LogError(
8401 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
8402 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8403 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8404 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8405 }
8406 } else {
8407 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
8408 skip |= LogError(
8409 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
8410 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8411 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8412 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8413 }
8414 }
8415 }
8416 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8417 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8418 skip |= LogError(
8419 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
8420 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8421 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8422 }
8423 }
8424 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8425 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
8426 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
8427 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
8428 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8429 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8430 }
8431 }
8432 } else if (pInfos[i].ppGeometries) {
8433 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8434 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
8435 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8436 skip |= LogError(
8437 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
8438 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8439 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8440 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8441 }
8442 } else {
8443 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
8444 skip |= LogError(
8445 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
8446 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8447 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8448 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8449 }
8450 }
8451 }
8452 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8453 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8454 skip |= LogError(
8455 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
8456 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8457 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8458 }
8459 }
8460 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8461 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
8462 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
8463 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
8464 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8465 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8466 }
8467 }
8468 }
8469 }
8470 }
8471 return skip;
8472}
8473
8474bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
8475 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
8476 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
8477 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
8478 bool skip = false;
8479 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
8480 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008481 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07008482 if (!ray_tracing_acceleration_structure_features ||
8483 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
8484 skip |=
8485 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
8486 "vkBuildAccelerationStructuresKHR: The "
8487 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
8488 }
8489 for (uint32_t i = 0; i < infoCount; ++i) {
8490 for (uint32_t j = 0; j < infoCount; ++j) {
8491 if (i == j) continue;
8492 bool found = false;
8493 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008494 skip |=
8495 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
8496 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
8497 ") of pInfos must "
8498 "not be "
8499 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8500 ") of pInfos.",
8501 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008502 found = true;
8503 }
8504 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008505 skip |=
8506 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
8507 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
8508 ") of pInfos must "
8509 "not be "
8510 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8511 ") of pInfos.",
8512 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008513 found = true;
8514 }
8515 if (found) break;
8516 }
8517 }
8518 return skip;
8519}
8520
8521bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
8522 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
8523 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
8524 bool skip = false;
8525 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
8526 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008527 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
8528 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
ziga-lunargbcfba982022-03-19 17:49:55 +01008529 if (!((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_TRUE) ||
8530 (ray_query_features && ray_query_features->rayQuery == VK_TRUE))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008531 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
Lars-Ivar Hesselberg Simonsendcd1e402021-11-23 17:14:03 +01008532 "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled");
8533 }
8534 if (pBuildInfo != nullptr) {
8535 if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) {
8536 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619",
8537 "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts "
8538 "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values");
8539 }
sourav parmarcd5fb182020-07-17 12:58:44 -07008540 }
8541 return skip;
8542}
sfricke-samsungecafb192021-01-17 08:21:14 -08008543
Piers Daniellcb6d8032021-04-19 18:51:26 -06008544bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
8545 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
8546 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
8547 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
8548 bool skip = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06008549 const auto *vertex_attribute_divisor_features =
8550 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
8551
Piers Daniellcb6d8032021-04-19 18:51:26 -06008552 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
8553 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
8554 skip |=
8555 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
8556 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
8557 }
8558
8559 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
8560 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
8561 skip |= LogError(
8562 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
8563 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
8564 }
8565
8566 // VUID-vkCmdSetVertexInputEXT-binding-04793
8567 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
8568 bool binding_found = false;
8569 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8570 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
8571 binding_found = true;
8572 break;
8573 }
8574 }
8575 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008576 skip |= LogError(
8577 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
8578 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008579 }
8580 }
8581
8582 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
8583 if (vertexBindingDescriptionCount > 1) {
8584 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
8585 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
8586 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
8587 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
8588 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008589 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
8590 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008591 }
8592 }
8593 }
8594 }
8595
8596 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
8597 if (vertexAttributeDescriptionCount > 1) {
8598 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
8599 uint32_t location = pVertexAttributeDescriptions[attribute].location;
8600 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
8601 if (location == pVertexAttributeDescriptions[next_attribute].location) {
8602 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008603 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
8604 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008605 }
8606 }
8607 }
8608 }
8609
8610 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8611 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
8612 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008613 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
8614 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8615 "].binding is greater than maxVertexInputBindings",
8616 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008617 }
8618
8619 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
8620 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008621 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
8622 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8623 "].stride is greater than maxVertexInputBindingStride",
8624 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008625 }
8626
8627 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
8628 if (pVertexBindingDescriptions[binding].divisor == 0 &&
8629 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
8630 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008631 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8632 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008633 "vertexAttributeInstanceRateZeroDivisor is not enabled",
8634 binding);
8635 }
8636
8637 if (pVertexBindingDescriptions[binding].divisor > 1) {
8638 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
8639 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
8640 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008641 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8642 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008643 "vertexAttributeInstanceRateDivisor is not enabled",
8644 binding);
8645 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008646 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06008647 if (pVertexBindingDescriptions[binding].divisor >
8648 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008649 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
8650 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8651 "].divisor is greater than maxVertexAttribDivisor",
8652 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008653 }
8654
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008655 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06008656 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008657 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
8658 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8659 "].divisor is greater than 1 but inputRate "
8660 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
8661 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008662 }
8663 }
8664 }
8665 }
8666
8667 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008668 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06008669 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008670 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
8671 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8672 "].location is greater than maxVertexInputAttributes",
8673 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008674 }
8675
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008676 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06008677 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008678 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
8679 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8680 "].binding is greater than maxVertexInputBindings",
8681 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008682 }
8683
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008684 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06008685 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008686 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
8687 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8688 "].offset is greater than maxVertexInputAttributeOffset",
8689 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008690 }
8691
8692 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
8693 VkFormatProperties properties;
8694 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
8695 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
8696 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008697 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8698 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008699 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
8700 attribute);
8701 }
8702 }
8703
8704 return skip;
8705}
sfricke-samsung51303fb2021-05-09 19:09:13 -07008706
8707bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
8708 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
8709 const void *pValues) const {
8710 bool skip = false;
8711 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
8712 // Check that offset + size don't exceed the max.
8713 // Prevent arithetic overflow here by avoiding addition and testing in this order.
8714 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008715 skip |=
8716 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
8717 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
8718 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008719 }
8720 if (size > max_push_constants_size - offset) {
8721 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008722 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
8723 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07008724 offset, size, max_push_constants_size);
8725 }
8726
8727 // size needs to be non-zero and a multiple of 4.
8728 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008729 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
8730 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008731 }
8732
8733 // offset needs to be a multiple of 4.
8734 if ((offset & 0x3) != 0) {
8735 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008736 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008737 }
8738 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06008739}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02008740
8741bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
8742 uint32_t srcCacheCount,
8743 const VkPipelineCache *pSrcCaches) const {
8744 bool skip = false;
8745 if (pSrcCaches) {
8746 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
8747 if (pSrcCaches[index0] == dstCache) {
8748 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
8749 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
8750 report_data->FormatHandle(dstCache).c_str());
8751 break;
8752 }
8753 }
8754 }
8755 return skip;
8756}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008757
8758bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
8759 VkImageLayout imageLayout, const VkClearColorValue *pColor,
8760 uint32_t rangeCount,
8761 const VkImageSubresourceRange *pRanges) const {
8762 bool skip = false;
8763 if (!pColor) {
8764 skip |=
8765 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
8766 }
8767 return skip;
8768}
8769
8770bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
8771 const VkRenderPassBeginInfo *const rp_begin) const {
8772 bool skip = false;
8773 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
8774 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
8775 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02008776 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008777 func_name, rp_begin->clearValueCount);
8778 }
8779 return skip;
8780}
8781
8782bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8783 VkSubpassContents) const {
8784 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
8785 return skip;
8786}
8787
8788bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
8789 const VkRenderPassBeginInfo *pRenderPassBegin,
8790 const VkSubpassBeginInfo *) const {
8791 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
8792 return skip;
8793}
8794
8795bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8796 const VkSubpassBeginInfo *) const {
8797 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
8798 return skip;
8799}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02008800
8801bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
8802 uint32_t firstDiscardRectangle,
8803 uint32_t discardRectangleCount,
8804 const VkRect2D *pDiscardRectangles) const {
8805 bool skip = false;
8806
8807 if (pDiscardRectangles) {
8808 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
8809 const int64_t x_sum =
8810 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
8811 if (x_sum > std::numeric_limits<int32_t>::max()) {
8812 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
8813 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8814 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8815 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
8816 }
8817
8818 const int64_t y_sum =
8819 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
8820 if (y_sum > std::numeric_limits<int32_t>::max()) {
8821 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
8822 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8823 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8824 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
8825 }
8826 }
8827 }
8828
8829 return skip;
8830}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02008831
8832bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
8833 uint32_t queryCount, size_t dataSize, void *pData,
8834 VkDeviceSize stride, VkQueryResultFlags flags) const {
8835 bool skip = false;
8836
8837 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
8838 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
8839 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
8840 }
8841
8842 return skip;
8843}
ziga-lunargcf340c42021-08-19 00:13:38 +02008844
8845bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
8846 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
8847 bool skip = false;
8848
8849 if ((pConditionalRenderingBegin->offset & 3) != 0) {
8850 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
8851 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
8852 ") is not a multiple of 4.",
8853 pConditionalRenderingBegin->offset);
8854 }
8855
8856 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06008857}
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008858
8859bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
8860 VkSurfaceKHR surface,
8861 uint32_t *pSurfaceFormatCount,
8862 VkSurfaceFormatKHR *pSurfaceFormats) const {
8863 bool skip = false;
8864 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8865 skip |= LogError(
8866 physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06524",
8867 "vkGetPhysicalDeviceSurfaceFormatsKHR(): surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8868 }
8869 return skip;
8870}
8871
8872bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
8873 VkSurfaceKHR surface,
8874 uint32_t *pPresentModeCount,
8875 VkPresentModeKHR *pPresentModes) const {
8876 bool skip = false;
8877 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8878 skip |= LogError(
8879 physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModesKHR-surface-06524",
8880 "vkGetPhysicalDeviceSurfacePresentModesKHR: surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8881 }
8882 return skip;
8883}
8884
8885bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceCapabilities2KHR(
8886 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
8887 VkSurfaceCapabilities2KHR *pSurfaceCapabilities) const {
8888 bool skip = false;
8889 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8890 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pSurfaceInfo-06520",
8891 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8892 "VK_GOOGLE_surfaceless_query is not enabled.");
8893 }
8894 return skip;
8895}
8896
8897bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormats2KHR(
8898 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pSurfaceFormatCount,
8899 VkSurfaceFormat2KHR *pSurfaceFormats) const {
8900 bool skip = false;
8901 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8902 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormats2KHR-pSurfaceInfo-06521",
8903 "vkGetPhysicalDeviceSurfaceFormats2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8904 "VK_GOOGLE_surfaceless_query is not enabled.");
8905 }
8906 return skip;
8907}
8908
8909#ifdef VK_USE_PLATFORM_WIN32_KHR
8910bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModes2EXT(
8911 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pPresentModeCount,
8912 VkPresentModeKHR *pPresentModes) const {
8913 bool skip = false;
8914 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8915 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
8916 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8917 "VK_GOOGLE_surfaceless_query is not enabled.");
8918 }
8919 return skip;
8920}
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008921
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008922#endif // VK_USE_PLATFORM_WIN32_KHR
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008923
8924bool StatelessValidation::ValidateDeviceImageMemoryRequirements(VkDevice device, const VkDeviceImageMemoryRequirementsKHR *pInfo,
8925 const char *func_name) const {
8926 bool skip = false;
8927
8928 if (pInfo && pInfo->pCreateInfo) {
8929 const auto *image_swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pInfo->pCreateInfo);
8930 if (image_swapchain_create_info) {
8931 skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirementsKHR-pCreateInfo-06416",
8932 "%s(): pInfo->pCreateInfo->pNext chain contains VkImageSwapchainCreateInfoKHR.", func_name);
8933 }
sjfricke7f73fbd2022-05-27 06:33:36 +09008934 const auto *drm_format_modifier_create_info =
8935 LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pInfo->pCreateInfo);
8936 if (drm_format_modifier_create_info) {
Mike Schuchardt75a4db52022-06-02 14:01:11 -07008937 skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirements-pCreateInfo-06776",
sjfricke7f73fbd2022-05-27 06:33:36 +09008938 "%s(): pInfo->pCreateInfo->pNext chain contains VkImageDrmFormatModifierExplicitCreateInfoEXT.",
8939 func_name);
8940 }
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008941 }
8942
8943 return skip;
8944}
8945
8946bool StatelessValidation::manual_PreCallValidateGetDeviceImageMemoryRequirementsKHR(
8947 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, VkMemoryRequirements2 *pMemoryRequirements) const {
8948 bool skip = false;
8949
8950 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageMemoryRequirementsKHR");
8951
8952 return skip;
8953}
8954
8955bool StatelessValidation::manual_PreCallValidateGetDeviceImageSparseMemoryRequirementsKHR(
8956 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, uint32_t *pSparseMemoryRequirementCount,
8957 VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) const {
8958 bool skip = false;
8959
8960 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageSparseMemoryRequirementsKHR");
8961
8962 return skip;
8963}
Tony-LunarG115f89d2022-06-15 10:53:22 -06008964
8965#ifdef VK_USE_PLATFORM_METAL_EXT
8966bool StatelessValidation::manual_PreCallValidateExportMetalObjectsEXT(VkDevice device,
8967 VkExportMetalObjectsInfoEXT *pMetalObjectsInfo) const {
8968 bool skip = false;
8969 const VkStructureType allowed_structs_vk_export_metal_objects_info[] = {
8970 VK_STRUCTURE_TYPE_EXPORT_METAL_BUFFER_INFO_EXT, VK_STRUCTURE_TYPE_EXPORT_METAL_COMMAND_QUEUE_INFO_EXT,
8971 VK_STRUCTURE_TYPE_EXPORT_METAL_DEVICE_INFO_EXT, VK_STRUCTURE_TYPE_EXPORT_METAL_IO_SURFACE_INFO_EXT,
8972 VK_STRUCTURE_TYPE_EXPORT_METAL_SHARED_EVENT_INFO_EXT, VK_STRUCTURE_TYPE_EXPORT_METAL_TEXTURE_INFO_EXT,
8973 };
8974 skip |= validate_struct_pnext("vkExportMetalObjectsEXT", "pMetalObjectsInfo->pNext",
8975 "VkExportMetalBufferInfoEXT, VkExportMetalCommandQueueInfoEXT, VkExportMetalDeviceInfoEXT, "
8976 "VkExportMetalIOSurfaceInfoEXT, VkExportMetalSharedEventInfoEXT, VkExportMetalTextureInfoEXT",
8977 pMetalObjectsInfo->pNext, ARRAY_SIZE(allowed_structs_vk_export_metal_objects_info),
8978 allowed_structs_vk_export_metal_objects_info, GeneratedVulkanHeaderVersion,
8979 "VUID-VkExportMetalObjectsInfoEXT-pNext-pNext", "VUID-VkExportMetalObjectsInfoEXT-sType-unique",
8980 false, true);
8981 return skip;
8982}
8983#endif // VK_USE_PLATFORM_METAL_EXT