blob: 52cd93472ae1cb5057220768d0c8686a5fc43def [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));
3607 } else if (color_attachment_count >=
3608 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,
4177 const VkMutableDescriptorTypeCreateInfoVALVE &mutable_create_info,
4178 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 }
4186 if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4187 if (mutable_type_count == 0) {
4188 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04597",
4189 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
4190 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE, but "
4191 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4192 "].descriptorTypeCount is 0.",
4193 func_name, i, i);
4194 }
4195 } else {
4196 if (mutable_type_count > 0) {
4197 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04599",
4198 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
4199 "].descriptorType is %s, but "
4200 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4201 "].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]) {
4210 case VK_DESCRIPTOR_TYPE_MUTABLE_VALVE:
4211 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04600",
4212 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4213 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.",
4214 func_name, j, k);
4215 break;
4216 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
4217 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04601",
4218 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4219 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.",
4220 func_name, j, k);
4221 break;
4222 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
4223 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04602",
4224 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4225 "].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:
4229 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04603",
4230 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4231 "].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 |=
4241 LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04598",
4242 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4243 "].pDescriptorTypes[%" PRIu32
4244 "] and VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4245 "].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
ziga-lunargfc6896f2021-10-15 18:46:12 +02004316 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
4317 const auto *mutable_descriptor_type_features = LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
4318 bool mutable_descriptor_type_features_enabled =
4319 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
4320
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004321 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4322 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
4323 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
4324 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004325 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4326 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
4327 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
4328 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
4329 ++descriptor_index) {
4330 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07004331 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004332 "vkCreateDescriptorSetLayout: required parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004333 "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32
4334 "] specified as VK_NULL_HANDLE",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004335 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004336 }
4337 }
4338 }
4339
4340 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
4341 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
4342 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004343 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004344 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4345 "].descriptorCount is not 0, "
4346 "pCreateInfo->pBindings[%" PRIu32
4347 "].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004348 "values.",
4349 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004350 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004351
4352 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
4353 (pCreateInfo->pBindings[i].stageFlags != 0) &&
4354 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004355 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
4356 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4357 "].descriptorCount is not 0 and "
4358 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32
4359 "].stageFlags "
4360 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
4361 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004362 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004363
4364 if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4365 if (!mutable_descriptor_type) {
4366 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04593",
4367 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4368 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4369 "VkMutableDescriptorTypeCreateInfoVALVE is not included in the pNext chain.",
4370 i);
4371 }
4372 if (pCreateInfo->pBindings[i].pImmutableSamplers) {
4373 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594",
4374 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4375 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4376 "pImmutableSamplers is not NULL.",
4377 i);
4378 }
4379 if (!mutable_descriptor_type_features_enabled) {
4380 skip |= LogError(
4381 device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595",
4382 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4383 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4384 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.",
4385 i);
4386 }
4387 }
4388
4389 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR &&
4390 pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4391 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591",
4392 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4393 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32
4394 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.", i);
4395 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004396 }
4397 }
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004398
4399 if (mutable_descriptor_type) {
paul-lunargef8ed7c2022-07-14 13:42:53 -06004400 skip |=
4401 ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type, "vkDescriptorSetLayoutCreateInfo");
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004402 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004403 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004404 if (pCreateInfo) {
4405 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) &&
4406 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4407 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590",
4408 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4409 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and "
4410 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4411 }
4412 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) &&
4413 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4414 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592",
4415 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4416 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and "
4417 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4418 }
4419 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE &&
4420 !mutable_descriptor_type_features_enabled) {
4421 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596",
4422 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4423 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE, but "
4424 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.");
4425 }
4426 }
4427
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004428 return skip;
4429}
4430
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004431bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
4432 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004433 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004434 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4435 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4436 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004437 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
4438 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004439}
4440
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004441bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
4442 const VkWriteDescriptorSet *pDescriptorWrites,
Mike Schuchardt979898a2022-01-11 10:46:59 -08004443 const bool isPushDescriptor) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004444 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004445
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004446 if (pDescriptorWrites != NULL) {
4447 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
4448 // descriptorCount must be greater than 0
4449 if (pDescriptorWrites[i].descriptorCount == 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004450 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
4451 "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.",
4452 vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004453 }
4454
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004455 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
Mike Schuchardt979898a2022-01-11 10:46:59 -08004456 if (!isPushDescriptor) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004457 // dstSet must be a valid VkDescriptorSet handle
4458 skip |= validate_required_handle(vkCallingFunction,
4459 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
4460 pDescriptorWrites[i].dstSet);
4461 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004462
4463 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4464 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
4465 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4466 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4467 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004468 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004469 if (!isPushDescriptor) {
4470 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4471 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or
4472 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pImageInfo must be a pointer to an array of descriptorCount valid
4473 // VkDescriptorImageInfo structures. Valid imageView handles are checked in
4474 // ObjectLifetimes::ValidateDescriptorWrite.
4475 skip |= LogError(
4476 device, "VUID-vkUpdateDescriptorSets-pDescriptorWrites-06493",
4477 "%s(): if pDescriptorWrites[%" PRIu32
4478 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
4479 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
4480 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
4481 vkCallingFunction, i, i);
4482 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4483 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4484 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
4485 // If called from vkCmdPushDescriptorSetKHR, pImageInfo is only requred for descriptor types
4486 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, and
4487 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
4488 skip |= LogError(device, "VUID-vkCmdPushDescriptorSetKHR-pDescriptorWrites-06494",
4489 "%s(): if pDescriptorWrites[%" PRIu32
4490 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE "
4491 "or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32
4492 "].pImageInfo must not be NULL.",
4493 vkCallingFunction, i, i);
4494 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004495 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
4496 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05004497 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
4498 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004499 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4500 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004501 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004502 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
4503 ParameterName::IndexVector{i, descriptor_index}),
4504 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06004505 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004506 }
4507 }
4508 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4509 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4510 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
4511 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
4512 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4513 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
4514 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05004515 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004516 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004517 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004518 "%s(): if pDescriptorWrites[%" PRIu32
4519 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004520 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
4521 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004522 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004523 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004524 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05004525 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004526 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05004527 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004528 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4529 ++descriptor_index) {
4530 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
4531 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
4532 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004533 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004534 "%s(): if pDescriptorWrites[%" PRIu32
4535 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01004536 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004537 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
4538 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05004539 }
4540 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004541 }
4542 }
4543 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
4544 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004545 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004546 }
4547
4548 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4549 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004550 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004551 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4552 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004553 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004554 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004555 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004556 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004557 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004558 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004559 }
4560 }
4561 }
4562 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4563 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004564 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004565 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4566 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004567 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004568 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004569 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004570 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004571 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004572 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004573 }
4574 }
4575 }
4576 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004577 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
4578 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08004579 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004580 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004581 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4582 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
4583 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
4584 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004585 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004586 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4587 pDescriptorWrites[i].descriptorCount);
4588 }
4589 // further checks only if we have right structtype
4590 if (pnext_struct) {
4591 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4592 skip |= LogError(
4593 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004594 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4595 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004596 ".",
4597 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07004598 }
sourav parmarbcee7512020-12-28 14:34:49 -08004599 if (pnext_struct->accelerationStructureCount == 0) {
4600 skip |= LogError(device,
4601 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004602 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004603 }
4604 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004605 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004606 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4607 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4608 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4609 skip |= LogError(device,
4610 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
4611 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004612 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004613 }
4614 }
4615 }
sourav parmarbcee7512020-12-28 14:34:49 -08004616 }
4617 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004618 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004619 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4620 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
4621 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
4622 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004623 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004624 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4625 pDescriptorWrites[i].descriptorCount);
4626 }
4627 // further checks only if we have right structtype
4628 if (pnext_struct) {
4629 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4630 skip |= LogError(
4631 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004632 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4633 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004634 ".",
4635 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07004636 }
sourav parmarbcee7512020-12-28 14:34:49 -08004637 if (pnext_struct->accelerationStructureCount == 0) {
4638 skip |= LogError(device,
4639 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004640 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004641 }
4642 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004643 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004644 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4645 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4646 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4647 skip |= LogError(device,
4648 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
4649 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004650 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004651 }
4652 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004653 }
4654 }
4655 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004656 }
4657 }
4658 return skip;
4659}
4660
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004661bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
4662 const VkWriteDescriptorSet *pDescriptorWrites,
4663 uint32_t descriptorCopyCount,
4664 const VkCopyDescriptorSet *pDescriptorCopies) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004665 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites, false);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004666}
4667
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004668bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004669 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004670 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004671 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
4672}
4673
sfricke-samsung681ab7b2020-10-29 01:53:35 -07004674bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
4675 const VkAllocationCallbacks *pAllocator,
4676 VkRenderPass *pRenderPass) const {
4677 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4678}
4679
Mike Schuchardt2df08912020-12-15 16:28:09 -08004680bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004681 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004682 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004683 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4684}
4685
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004686bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
4687 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004688 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004689 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004690
4691 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4692 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4693 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004694 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
4695 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004696 return skip;
4697}
4698
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004699bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004700 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004701 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02004702
4703 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
4704 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07004705 bool cb_is_secondary;
4706 {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06004707 auto lock = CBReadLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07004708 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
4709 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004710
Tony-LunarG3c287f62020-12-17 12:39:49 -07004711 if (cb_is_secondary) {
4712 // Implicit VUs
4713 // validate only sType here; pointer has to be validated in core_validation
4714 const bool k_not_required = false;
4715 const char *k_no_vuid = nullptr;
4716 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
4717 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004718 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
4719 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004720
Tony-LunarG3c287f62020-12-17 12:39:49 -07004721 if (info) {
4722 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07004723 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
amhagana448ea52021-11-02 14:09:14 -04004724 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
4725 VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD,
David Zhao Akeley44139b12021-04-26 16:16:13 -07004726 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004727 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004728 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4729 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4730 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4731 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004732
Tony-LunarG3c287f62020-12-17 12:39:49 -07004733 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004734
Tony-LunarG3c287f62020-12-17 12:39:49 -07004735 // Explicit VUs
4736 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004737 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004738 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4739 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4740 cmd_name);
4741 }
4742
4743 if (physical_device_features.inheritedQueries) {
4744 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004745 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4746 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4747 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004748 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004749 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004750 }
4751
4752 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004753 skip |=
4754 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4755 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4756 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4757 } else { // !pipelineStatisticsQuery
4758 skip |=
4759 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4760 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004761 }
4762
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004763 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004764 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004765 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004766 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4767 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4768 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004769 commandBuffer,
4770 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004771 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4772 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4773 }
Petr Kraus139757b2019-08-15 17:19:33 +02004774 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004775
4776 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4777 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4778 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4779 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4780 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4781 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4782 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4783 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4784 }
Petr Kraus139757b2019-08-15 17:19:33 +02004785 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004786 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004787 return skip;
4788}
4789
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004790bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004791 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004792 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004793
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004794 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004795 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004796 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4797 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4798 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004799 }
4800 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004801 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4802 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4803 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004804 }
4805 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004806 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004807 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004808 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4809 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4810 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4811 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004812 }
4813 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004814
4815 if (pViewports) {
4816 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4817 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004818 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004819 skip |= manual_PreCallValidateViewport(
4820 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004821 }
4822 }
4823
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004824 return skip;
4825}
4826
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004827bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004828 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004829 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004830
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004831 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004832 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004833 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4834 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4835 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004836 }
4837 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004838 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4839 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4840 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004841 }
4842 } else { // multiViewport enabled
4843 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004844 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004845 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4846 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4847 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4848 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004849 }
4850 }
4851
Petr Kraus6260f0a2018-02-27 21:15:55 +01004852 if (pScissors) {
4853 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4854 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004855
Petr Kraus6260f0a2018-02-27 21:15:55 +01004856 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004857 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4858 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4859 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004860 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004861
Petr Kraus6260f0a2018-02-27 21:15:55 +01004862 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004863 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4864 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4865 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004866 }
4867
4868 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4869 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004870 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4871 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4872 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4873 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004874 }
4875
4876 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4877 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004878 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4879 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4880 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4881 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004882 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004883 }
4884 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004885
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004886 return skip;
4887}
4888
Jeff Bolz5c801d12019-10-09 10:38:45 -05004889bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004890 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004891
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004892 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004893 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4894 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004895 }
4896
4897 return skip;
4898}
4899
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004900bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004901 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004902 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004903
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004904 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004905 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sjfricke91d9bda2022-08-01 21:44:17 +09004906 "vkCmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004907 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004908 }
4909 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004910 skip |=
4911 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
sjfricke91d9bda2022-08-01 21:44:17 +09004912 "vkCmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004913 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004914 }
sjfricke91d9bda2022-08-01 21:44:17 +09004915 if (offset & 3) {
4916 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-offset-02710",
4917 "vkCmdDrawIndirect(): offset (%" PRIxLEAST64 ") must be a multiple of 4.", offset);
4918 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004919 return skip;
4920}
4921
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004922bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004923 VkDeviceSize offset, uint32_t drawCount,
4924 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004925 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004926 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sjfricke91d9bda2022-08-01 21:44:17 +09004927 skip |= LogError(
4928 device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4929 "vkCmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4930 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004931 }
4932 if (drawCount > device_limits.maxDrawIndirectCount) {
4933 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sjfricke91d9bda2022-08-01 21:44:17 +09004934 "vkCmdDrawIndexedIndirect(): drawCount (%" PRIu32
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004935 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004936 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004937 }
sjfricke91d9bda2022-08-01 21:44:17 +09004938 if (offset & 3) {
4939 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-offset-02710",
4940 "vkCmdDrawIndexedIndirect(): offset (%" PRIxLEAST64 ") must be a multiple of 4.", offset);
4941 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004942 return skip;
4943}
4944
sfricke-samsungf692b972020-05-02 08:00:45 -07004945bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
sjfricke91d9bda2022-08-01 21:44:17 +09004946 VkDeviceSize countBufferOffset, CMD_TYPE cmd_type) const {
sfricke-samsungf692b972020-05-02 08:00:45 -07004947 bool skip = false;
sfricke-samsungf692b972020-05-02 08:00:45 -07004948 if (offset & 3) {
4949 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
sjfricke91d9bda2022-08-01 21:44:17 +09004950 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4951 CommandTypeString(cmd_type), offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004952 }
4953
4954 if (countBufferOffset & 3) {
4955 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
sjfricke91d9bda2022-08-01 21:44:17 +09004956 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4957 CommandTypeString(cmd_type), countBufferOffset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004958 }
4959 return skip;
4960}
4961
4962bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4963 VkDeviceSize offset, VkBuffer countBuffer,
4964 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4965 uint32_t stride) const {
sjfricke91d9bda2022-08-01 21:44:17 +09004966 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, CMD_DRAWINDIRECTCOUNT);
4967}
4968
4969bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer,
4970 VkDeviceSize offset, VkBuffer countBuffer,
4971 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4972 uint32_t stride) const {
4973 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, CMD_DRAWINDIRECTCOUNTAMD);
sfricke-samsungf692b972020-05-02 08:00:45 -07004974}
4975
4976bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4977 VkDeviceSize offset, VkBuffer countBuffer,
4978 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4979 uint32_t stride) const {
sjfricke91d9bda2022-08-01 21:44:17 +09004980 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, CMD_DRAWINDIRECTCOUNTKHR);
sfricke-samsungf692b972020-05-02 08:00:45 -07004981}
4982
4983bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
sjfricke91d9bda2022-08-01 21:44:17 +09004984 VkDeviceSize countBufferOffset, CMD_TYPE cmd_type) const {
sfricke-samsungf692b972020-05-02 08:00:45 -07004985 bool skip = false;
sfricke-samsungf692b972020-05-02 08:00:45 -07004986 if (offset & 3) {
4987 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
sjfricke91d9bda2022-08-01 21:44:17 +09004988 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4989 CommandTypeString(cmd_type), offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004990 }
4991
4992 if (countBufferOffset & 3) {
4993 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
sjfricke91d9bda2022-08-01 21:44:17 +09004994 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4995 CommandTypeString(cmd_type), countBufferOffset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004996 }
4997 return skip;
4998}
4999
5000bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
5001 VkDeviceSize offset, VkBuffer countBuffer,
5002 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
5003 uint32_t stride) const {
sjfricke91d9bda2022-08-01 21:44:17 +09005004 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, CMD_DRAWINDEXEDINDIRECTCOUNT);
5005}
5006
5007bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer,
5008 VkDeviceSize offset, VkBuffer countBuffer,
5009 VkDeviceSize countBufferOffset,
5010 uint32_t maxDrawCount, uint32_t stride) const {
5011 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, CMD_DRAWINDEXEDINDIRECTCOUNTAMD);
sfricke-samsungf692b972020-05-02 08:00:45 -07005012}
5013
5014bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
5015 VkDeviceSize offset, VkBuffer countBuffer,
5016 VkDeviceSize countBufferOffset,
5017 uint32_t maxDrawCount, uint32_t stride) const {
sjfricke91d9bda2022-08-01 21:44:17 +09005018 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, CMD_DRAWINDEXEDINDIRECTCOUNTKHR);
sfricke-samsungf692b972020-05-02 08:00:45 -07005019}
5020
Tony-LunarG4490de42021-06-21 15:49:19 -06005021bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
5022 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
5023 uint32_t firstInstance, uint32_t stride) const {
5024 bool skip = false;
5025 if (stride & 3) {
5026 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
5027 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
5028 }
5029 if (drawCount && nullptr == pVertexInfo) {
5030 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
5031 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
5032 "one or more valid instances of VkMultiDrawInfoEXT structures");
5033 }
5034 return skip;
5035}
5036
5037bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
5038 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
5039 uint32_t instanceCount, uint32_t firstInstance,
5040 uint32_t stride, const int32_t *pVertexOffset) const {
5041 bool skip = false;
5042 if (stride & 3) {
5043 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
5044 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
5045 }
5046 if (drawCount && nullptr == pIndexInfo) {
5047 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
5048 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
5049 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
5050 }
5051 return skip;
5052}
5053
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06005054bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
5055 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005056 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06005057 bool skip = false;
5058 for (uint32_t rect = 0; rect < rectCount; rect++) {
5059 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005060 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005061 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06005062 }
sfricke-samsung10867682020-04-25 02:20:39 -07005063 if (pRects[rect].rect.extent.width == 0) {
5064 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005065 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07005066 }
5067 if (pRects[rect].rect.extent.height == 0) {
5068 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005069 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07005070 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06005071 }
5072 return skip;
5073}
5074
Andrew Fobel3abeb992020-01-20 16:33:22 -05005075bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
5076 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
5077 VkImageFormatProperties2 *pImageFormatProperties,
5078 const char *apiName) const {
5079 bool skip = false;
5080
5081 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005082 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05005083 if (image_stencil_struct != nullptr) {
5084 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
5085 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
5086 // No flags other than the legal attachment bits may be set
5087 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
5088 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005089 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
5090 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
5091 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
5092 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
5093 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05005094 }
5095 }
5096 }
ziga-lunargd3da2532021-08-11 11:50:12 +02005097 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
5098 if (image_drm_format) {
5099 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
5100 skip |= LogError(
5101 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
5102 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
5103 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
5104 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
5105 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02005106 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
5107 skip |= LogError(
5108 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
5109 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
5110 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
5111 apiName, image_drm_format->queueFamilyIndexCount);
5112 }
ziga-lunargd3da2532021-08-11 11:50:12 +02005113 } else {
5114 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
5115 skip |= LogError(
5116 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
5117 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
5118 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
5119 apiName);
5120 }
5121 }
5122 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
5123 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
5124 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
5125 if (!format_list || format_list->viewFormatCount == 0) {
5126 skip |= LogError(
5127 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
5128 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
5129 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
5130 apiName);
5131 }
5132 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05005133 }
5134
5135 return skip;
5136}
5137
5138bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
5139 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
5140 VkImageFormatProperties2 *pImageFormatProperties) const {
5141 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
5142 "vkGetPhysicalDeviceImageFormatProperties2");
5143}
5144
5145bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
5146 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
5147 VkImageFormatProperties2 *pImageFormatProperties) const {
5148 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
5149 "vkGetPhysicalDeviceImageFormatProperties2KHR");
5150}
5151
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03005152bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
5153 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
5154 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
5155 bool skip = false;
5156
5157 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
5158 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
5159 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
5160 }
5161
5162 return skip;
5163}
5164
sfricke-samsung3999ef62020-02-09 17:05:59 -08005165bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
5166 uint32_t regionCount, const VkBufferCopy *pRegions) const {
5167 bool skip = false;
5168
5169 if (pRegions != nullptr) {
5170 for (uint32_t i = 0; i < regionCount; i++) {
5171 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005172 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005173 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08005174 }
5175 }
5176 }
5177 return skip;
5178}
5179
Jeff Leger178b1e52020-10-05 12:22:23 -04005180bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
5181 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
5182 bool skip = false;
5183
5184 if (pCopyBufferInfo->pRegions != nullptr) {
5185 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
5186 if (pCopyBufferInfo->pRegions[i].size == 0) {
Tony-LunarGef035472021-11-02 10:23:33 -06005187 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005188 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04005189 }
5190 }
5191 }
5192 return skip;
5193}
5194
Tony-LunarGef035472021-11-02 10:23:33 -06005195bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2(VkCommandBuffer commandBuffer,
5196 const VkCopyBufferInfo2 *pCopyBufferInfo) const {
5197 bool skip = false;
5198
5199 if (pCopyBufferInfo->pRegions != nullptr) {
5200 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
5201 if (pCopyBufferInfo->pRegions[i].size == 0) {
5202 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
5203 "vkCmdCopyBuffer2() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
5204 }
5205 }
5206 }
5207 return skip;
5208}
5209
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005210bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005211 VkDeviceSize dstOffset, VkDeviceSize dataSize,
5212 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005213 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005214
5215 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005216 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
5217 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5218 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005219 }
5220
5221 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005222 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
5223 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
5224 "), must be greater than zero and less than or equal to 65536.",
5225 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005226 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005227 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
5228 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5229 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005230 }
5231 return skip;
5232}
5233
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005234bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005235 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005236 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005237
5238 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005239 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
5240 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5241 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005242 }
5243
5244 if (size != VK_WHOLE_SIZE) {
5245 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005246 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005247 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
5248 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005249 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005250 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
5251 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005252 }
5253 }
5254 return skip;
5255}
5256
sfricke-samsunga1d00272021-03-10 21:37:41 -08005257bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005258 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005259
5260 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005261 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5262 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
5263 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
5264 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005265 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005266 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
5267 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
5268 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005269 }
5270
5271 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
5272 // queueFamilyIndexCount uint32_t values
5273 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005274 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005275 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005276 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08005277 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
5278 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005279 }
5280 }
5281
Dave Houlton413a6782018-05-22 13:01:54 -06005282 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005283 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005284
sfricke-samsunga1d00272021-03-10 21:37:41 -08005285 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
5286 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
5287 if (format_list_info) {
5288 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
5289 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
5290 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
5291 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005292 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
5293 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005294 func_name, viewFormatCount);
5295 }
5296
5297 // Using the first format, compare the rest of the formats against it that they are compatible
5298 for (uint32_t i = 1; i < viewFormatCount; i++) {
5299 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
5300 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
5301 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
5302 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005303 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
5304 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005305 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
5306 string_VkFormat(format_list_info->pViewFormats[i]));
5307 }
5308 }
5309 }
5310
5311 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
5312 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
5313 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
5314 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
5315 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
5316 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
5317 func_name);
5318 } else {
5319 if (format_list_info == nullptr) {
5320 skip |= LogError(
5321 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5322 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
5323 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
5324 func_name);
5325 } else if (format_list_info->viewFormatCount == 0) {
5326 skip |= LogError(
5327 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5328 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
5329 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
5330 func_name);
5331 } else {
5332 bool found_base_format = false;
5333 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
5334 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
5335 found_base_format = true;
5336 break;
5337 }
5338 }
5339 if (!found_base_format) {
5340 skip |=
5341 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5342 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
5343 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
5344 "pCreateInfo->imageFormat.",
5345 func_name);
5346 }
5347 }
5348 }
5349 }
5350 }
5351 return skip;
5352}
5353
5354bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
5355 const VkAllocationCallbacks *pAllocator,
5356 VkSwapchainKHR *pSwapchain) const {
5357 bool skip = false;
5358 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
5359 return skip;
5360}
5361
5362bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
5363 const VkSwapchainCreateInfoKHR *pCreateInfos,
5364 const VkAllocationCallbacks *pAllocator,
5365 VkSwapchainKHR *pSwapchains) const {
5366 bool skip = false;
5367 if (pCreateInfos) {
5368 for (uint32_t i = 0; i < swapchainCount; i++) {
5369 std::stringstream func_name;
5370 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
5371 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
5372 }
5373 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005374 return skip;
5375}
5376
Jeff Bolz5c801d12019-10-09 10:38:45 -05005377bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005378 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005379
5380 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005381 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06005382 if (present_regions) {
5383 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07005384 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06005385 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
5386 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07005387 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005388 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
5389 "extension swapchainCount is %i. These values must be equal.",
5390 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06005391 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005392 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08005393 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
5394 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005395 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
5396 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
5397 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06005398 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005399 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005400 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06005401 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005402 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005403 }
5404 }
5405
5406 return skip;
5407}
5408
sfricke-samsung5c1b7392020-12-13 22:17:15 -08005409bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
5410 const VkDisplayModeCreateInfoKHR *pCreateInfo,
5411 const VkAllocationCallbacks *pAllocator,
5412 VkDisplayModeKHR *pMode) const {
5413 bool skip = false;
5414
5415 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
5416 if (display_mode_parameters.visibleRegion.width == 0) {
5417 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
5418 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
5419 }
5420 if (display_mode_parameters.visibleRegion.height == 0) {
5421 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
5422 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
5423 }
5424 if (display_mode_parameters.refreshRate == 0) {
5425 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
5426 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
5427 }
5428
5429 return skip;
5430}
5431
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005432#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005433bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
5434 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
5435 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005436 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005437 bool skip = false;
5438
5439 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005440 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
5441 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005442 }
5443
5444 return skip;
5445}
5446#endif // VK_USE_PLATFORM_WIN32_KHR
5447
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005448static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
5449 bool partial_overlap = false;
5450
5451 static const std::vector<VkDescriptorType> all_descriptor_types = {
5452 VK_DESCRIPTOR_TYPE_SAMPLER,
5453 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
5454 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
5455 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
5456 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
5457 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
5458 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
5459 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
5460 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
5461 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
5462 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
5463 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
5464 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
5465 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
5466 };
5467
5468 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
5469 if (mutable_descriptor_type) {
5470 std::vector<VkDescriptorType> first_types, second_types;
5471 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
5472 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
5473 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
5474 }
5475 } else {
5476 first_types = all_descriptor_types;
5477 }
5478 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
5479 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
5480 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
5481 }
5482 } else {
5483 second_types = all_descriptor_types;
5484 }
5485
5486 bool complete_overlap = first_types.size() == second_types.size();
5487 bool disjoint = true;
5488 for (const auto first_type : first_types) {
5489 bool found = false;
5490 for (const auto second_type : second_types) {
5491 if (first_type == second_type) {
5492 found = true;
5493 break;
5494 }
5495 }
5496 if (found) {
5497 disjoint = false;
5498 } else {
5499 complete_overlap = false;
5500 }
5501 if (!disjoint && !complete_overlap) {
5502 partial_overlap = true;
5503 break;
5504 }
5505 }
5506 }
5507
5508 return partial_overlap;
5509}
5510
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005511bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005512 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005513 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02005514 bool skip = false;
5515
5516 if (pCreateInfo) {
5517 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005518 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
5519 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02005520 }
5521
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005522 const auto *mutable_descriptor_type_features =
5523 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
5524 bool mutable_descriptor_type_enabled =
5525 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
5526
Petr Krausc8655be2017-09-27 18:56:51 +02005527 if (pCreateInfo->pPoolSizes) {
5528 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
5529 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005530 skip |= LogError(
5531 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005532 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02005533 }
Jeff Bolze54ae892018-09-08 12:16:29 -05005534 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
5535 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005536 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
5537 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5538 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
5539 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
5540 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05005541 }
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005542 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) {
5543 skip |=
5544 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
5545 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5546 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5547 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.",
5548 i);
5549 }
5550 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5551 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
5552 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5553 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
5554 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
5555 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5556 "].type and pCreateInfo->pPoolSizes[%" PRIu32
5557 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5558 " and have sets which partially overlap.",
5559 i, j);
5560 }
5561 }
5562 }
5563 }
Petr Krausc8655be2017-09-27 18:56:51 +02005564 }
5565 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005566
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005567 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) {
5568 skip |=
5569 LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
5570 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, "
5571 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.");
5572 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005573 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
5574 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
5575 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
5576 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
5577 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
5578 }
Petr Krausc8655be2017-09-27 18:56:51 +02005579 }
5580
5581 return skip;
5582}
5583
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005584bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005585 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005586 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005587
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005588 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005589 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005590 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
5591 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5592 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005593 }
5594
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005595 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005596 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005597 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
5598 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5599 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005600 }
5601
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005602 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005603 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005604 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
5605 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5606 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005607 }
5608
5609 return skip;
5610}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005611
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005612bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005613 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07005614 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07005615
sjfricke91d9bda2022-08-01 21:44:17 +09005616 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005617 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
sjfricke91d9bda2022-08-01 21:44:17 +09005618 "vkCmdDispatchIndirect(): offset (%" PRIxLEAST64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005619 }
5620 return skip;
5621}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005622
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005623bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5624 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005625 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005626 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005627
5628 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005629 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005630 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005631 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5632 "vkCmdDispatch(): baseGroupX (%" PRIu32
5633 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5634 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005635 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005636 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5637 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5638 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5639 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005640 }
5641
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005642 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005643 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005644 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5645 "vkCmdDispatch(): baseGroupY (%" PRIu32
5646 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5647 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005648 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005649 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5650 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5651 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5652 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005653 }
5654
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005655 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005656 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005657 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5658 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5659 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5660 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005661 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005662 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5663 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5664 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5665 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005666 }
5667
5668 return skip;
5669}
5670
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005671bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5672 VkPipelineBindPoint pipelineBindPoint,
5673 VkPipelineLayout layout, uint32_t set,
5674 uint32_t descriptorWriteCount,
5675 const VkWriteDescriptorSet *pDescriptorWrites) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08005676 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, true);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005677}
5678
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005679bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5680 uint32_t firstExclusiveScissor,
5681 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005682 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005683 bool skip = false;
5684
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005685 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005686 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005687 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005688 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5689 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5690 ") is not 0.",
5691 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005692 }
5693 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005694 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005695 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5696 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5697 ") is not 1.",
5698 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005699 }
5700 } else { // multiViewport enabled
5701 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005702 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005703 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5704 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5705 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5706 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005707 }
5708 }
5709
Jeff Bolz3e71f782018-08-29 23:15:45 -05005710 if (pExclusiveScissors) {
5711 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5712 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5713
5714 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005715 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5716 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5717 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005718 }
5719
5720 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005721 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5722 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5723 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005724 }
5725
5726 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5727 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005728 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5729 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5730 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5731 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005732 }
5733
5734 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5735 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005736 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5737 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5738 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5739 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005740 }
5741 }
5742 }
5743
5744 return skip;
5745}
5746
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005747bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5748 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005749 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005750 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005751 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5752 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5753 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5754 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5755 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5756 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005757 }
5758
5759 return skip;
5760}
5761
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005762bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5763 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005764 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005765 bool skip = false;
5766
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005767 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005768 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005769 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005770 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5771 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5772 ") is not 0.",
5773 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005774 }
5775 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005776 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005777 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5778 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5779 ") is not 1.",
5780 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005781 }
5782 }
5783
Jeff Bolz9af91c52018-09-01 21:53:57 -05005784 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005785 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005786 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5787 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5788 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5789 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005790 }
5791
5792 return skip;
5793}
5794
Jeff Bolz5c801d12019-10-09 10:38:45 -05005795bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5796 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5797 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005798 bool skip = false;
5799
Dave Houlton142c4cb2018-10-17 15:04:41 -06005800 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005801 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5802 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5803 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005804 }
5805
5806 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005807 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005808 }
5809
5810 return skip;
5811}
5812
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005813bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005814 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005815 bool skip = false;
5816
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005817 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005818 skip |= LogError(
5819 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005820 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5821 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005822 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005823 }
5824
5825 return skip;
5826}
5827
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005828bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5829 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005830 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005831 bool skip = false;
sjfricke91d9bda2022-08-01 21:44:17 +09005832 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005833 skip |= LogError(
5834 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005835 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005836 }
sjfricke91d9bda2022-08-01 21:44:17 +09005837 if (drawCount > 1 && ((stride & 3) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005838 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5839 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5840 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5841 stride);
Lockee1c22882019-06-10 16:02:54 -06005842 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005843 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005844 skip |= LogError(
5845 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005846 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5847 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005848 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005849 if (drawCount > device_limits.maxDrawIndirectCount) {
5850 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005851 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5852 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005853 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005854 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005855 return skip;
5856}
5857
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005858bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5859 VkDeviceSize offset, VkBuffer countBuffer,
5860 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005861 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005862 bool skip = false;
5863
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005864 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005865 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5866 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5867 "), is not a multiple of 4.",
5868 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005869 }
5870
5871 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005872 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5873 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5874 "), is not a multiple of 4.",
5875 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005876 }
5877
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005878 return skip;
5879}
5880
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005881bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005882 const VkAllocationCallbacks *pAllocator,
5883 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005884 bool skip = false;
5885
5886 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5887 if (pCreateInfo != nullptr) {
5888 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5889 // VkQueryPipelineStatisticFlagBits values
5890 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5891 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005892 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5893 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5894 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5895 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005896 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005897 if (pCreateInfo->queryCount == 0) {
5898 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5899 "vkCreateQueryPool(): queryCount must be greater than zero.");
5900 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005901 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005902 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005903}
5904
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005905bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5906 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005907 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005908 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5909 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005910}
5911
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005912void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005913 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5914 VkResult result) {
5915 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005916 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005917}
5918
Mike Schuchardt2df08912020-12-15 16:28:09 -08005919void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005920 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5921 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005922 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005923 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005924 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005925}
5926
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005927void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5928 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005929 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005930 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005931 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005932}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005933
Tony-LunarG3c287f62020-12-17 12:39:49 -07005934void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005935 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005936 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005937 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005938 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005939 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005940 }
5941 }
5942}
5943
5944void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005945 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005946 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005947 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5948 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5949 }
5950}
5951
5952void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005953 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005954 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005955 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5956 if (item->second == commandPool) {
5957 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005958 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005959 ++item;
5960 }
5961 }
5962}
5963
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005964bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005965 const VkAllocationCallbacks *pAllocator,
5966 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005967 bool skip = false;
5968
5969 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005970 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005971 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005972 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5973 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005974 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005975
5976 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005977 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005978 if (flags_info) {
5979 flags = flags_info->flags;
5980 }
5981
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005982 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005983 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005984 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005985 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5986 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005987 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005988 }
5989
5990#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005991 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005992#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005993 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5994 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005995#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005996 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005997#endif
5998
5999 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006000 skip |= LogError(
6001 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06006002 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
6003 }
6004 if (
6005#ifdef VK_USE_PLATFORM_WIN32_KHR
6006 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
6007#endif
6008 (import_memory_fd && import_memory_fd->handleType) ||
6009#ifdef VK_USE_PLATFORM_ANDROID_KHR
6010 (import_memory_ahb && import_memory_ahb->buffer) ||
6011#endif
6012 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006013 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
6014 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06006015 }
6016 }
6017
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02006018 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
6019 if (export_memory) {
6020 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
6021 if (export_memory_nv) {
6022 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
6023 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
6024 "VkExportMemoryAllocateInfoNV");
6025 }
6026#ifdef VK_USE_PLATFORM_WIN32_KHR
6027 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
6028 if (export_memory_win32_nv) {
6029 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
6030 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
6031 "VkExportMemoryWin32HandleInfoNV");
6032 }
6033#endif
6034 }
6035
Jeff Bolz4563f2a2019-12-10 13:30:30 -06006036 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07006037 VkBool32 capture_replay = false;
6038 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006039 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07006040 if (vulkan_12_features) {
6041 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
6042 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
6043 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006044 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07006045 if (bda_features) {
6046 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
6047 buffer_device_address = bda_features->bufferDeviceAddress;
6048 }
6049 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08006050 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006051 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08006052 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006053 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06006054 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08006055 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006056 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08006057 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06006058 }
6059 }
Tony-LunarG115f89d2022-06-15 10:53:22 -06006060#ifdef VK_USE_PLATFORM_METAL_EXT
6061 skip |= ExportMetalObjectsPNextUtil(
6062 VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT, "VUID-VkMemoryAllocateInfo-pNext-06780",
6063 "vkAllocateMemory():", "VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT", pAllocateInfo->pNext);
6064#endif // VK_USE_PLATFORM_METAL_EXT
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06006065 }
6066 return skip;
6067}
Ricardo Garciaa4935972019-02-21 17:43:18 +01006068
Jason Macnak192fa0e2019-07-26 15:07:16 -07006069bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006070 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07006071 bool skip = false;
6072
6073 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
6074 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
6075 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006076 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006077 } else {
6078 uint32_t vertex_component_size = 0;
6079 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
6080 vertex_component_size = 4;
6081 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
6082 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
6083 vertex_component_size = 2;
6084 }
6085 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006086 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006087 }
6088 }
6089
6090 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6091 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006092 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006093 } else {
6094 uint32_t index_element_size = 0;
6095 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
6096 index_element_size = 4;
6097 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
6098 index_element_size = 2;
6099 }
6100 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006101 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006102 }
6103 }
6104 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
6105 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006106 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006107 }
6108 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006109 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006110 }
6111 }
6112
6113 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006114 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006115 }
6116
6117 return skip;
6118}
6119
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006120bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
6121 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07006122 bool skip = false;
6123
6124 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006125 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006126 }
6127 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006128 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006129 }
6130
6131 return skip;
6132}
6133
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006134bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
6135 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07006136 bool skip = false;
6137 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006138 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006139 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006140 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006141 }
6142 return skip;
6143}
6144
6145bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07006146 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06006147 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006148 bool skip = false;
6149 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006150 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
6151 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
6152 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07006153 }
6154 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006155 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
6156 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
6157 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07006158 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02006159 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6160 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
6161 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
6162 }
Jason Macnak5c954952019-07-09 15:46:12 -07006163 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
6164 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006165 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
6166 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
6167 "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 -07006168 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006169 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006170 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06006171 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
6172 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006173 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
6174 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07006175 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006176 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006177 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
6178 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
6179 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07006180 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07006181 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07006182 uint64_t total_triangle_count = 0;
6183 for (uint32_t i = 0; i < info.geometryCount; i++) {
6184 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07006185
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006186 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006187
Jason Macnak5c954952019-07-09 15:46:12 -07006188 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
6189 continue;
6190 }
6191 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
6192 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006193 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006194 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
6195 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
6196 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07006197 }
6198 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07006199 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
6200 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
6201 for (uint32_t i = 1; i < info.geometryCount; i++) {
6202 const VkGeometryNV &geometry = info.pGeometries[i];
6203 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006204 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006205 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
6206 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006207 "info.pGeometries[0].geometryType.",
6208 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07006209 }
6210 }
6211 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006212 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
6213 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
6214 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
6215 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
6216 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
6217 "or VK_GEOMETRY_TYPE_AABBS_NV.");
6218 }
6219 }
6220 skip |=
6221 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06006222 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07006223 return skip;
6224}
6225
Ricardo Garciaa4935972019-02-21 17:43:18 +01006226bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
6227 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006228 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01006229 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01006230 if (pCreateInfo) {
6231 if ((pCreateInfo->compactedSize != 0) &&
6232 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006233 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
6234 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
6235 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
6236 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01006237 }
Jason Macnak5c954952019-07-09 15:46:12 -07006238
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006239 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07006240 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01006241 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01006242 return skip;
6243}
Mike Schuchardt21638df2019-03-16 10:52:02 -07006244
Jeff Bolz5c801d12019-10-09 10:38:45 -05006245bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
6246 const VkAccelerationStructureInfoNV *pInfo,
6247 VkBuffer instanceData, VkDeviceSize instanceOffset,
6248 VkBool32 update, VkAccelerationStructureNV dst,
6249 VkAccelerationStructureNV src, VkBuffer scratch,
6250 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006251 bool skip = false;
6252
6253 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006254 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07006255 }
6256
6257 return skip;
6258}
6259
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006260bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
6261 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6262 VkAccelerationStructureKHR *pAccelerationStructure) const {
6263 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006264 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006265 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006266 if (!acceleration_structure_features ||
6267 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
6268 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
6269 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
6270 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006271 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006272 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
6273 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006274 (acceleration_structure_features &&
6275 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07006276 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07006277 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
6278 "vkCreateAccelerationStructureKHR(): If createFlags includes "
6279 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
6280 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07006281 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006282 if (pCreateInfo->deviceAddress &&
6283 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
6284 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
6285 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
6286 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
6287 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006288 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
6289 (acceleration_structure_features &&
6290 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
6291 skip |= LogError(
6292 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
6293 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
6294 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
6295 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006296 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
6297 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006298 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
6299 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07006300 }
sourav parmar83c31b12020-05-06 12:30:54 -07006301 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006302 return skip;
6303}
6304
Jason Macnak5c954952019-07-09 15:46:12 -07006305bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
6306 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006307 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006308 bool skip = false;
6309 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006310 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
6311 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07006312 }
6313 return skip;
6314}
6315
sourav parmarcd5fb182020-07-17 12:58:44 -07006316bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
6317 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
6318 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6319 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006320 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07006321 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07006322 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006323 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006324 }
6325 return skip;
6326}
6327
Peter Chen85366392019-05-14 15:20:11 -04006328bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
6329 uint32_t createInfoCount,
6330 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
6331 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006332 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04006333 bool skip = false;
6334
6335 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006336 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6337 std::stringstream msg;
6338 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6339 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
6340 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006341 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04006342 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06006343 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineStageCreationFeedbackCount-06651",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006344 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
6345 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
6346 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
6347 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04006348 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006349
6350 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006351 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006352 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6353 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6354 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6355 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
6356 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
6357 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6358 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6359 }
6360 }
6361
sourav parmarf4a78252020-04-10 13:04:21 -07006362 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
6363 skip |=
6364 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
6365 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
6366 }
6367 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
6368 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
6369 skip |=
6370 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
6371 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
6372 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
6373 }
6374 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6375 if (pCreateInfos[i].basePipelineIndex != -1) {
6376 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6377 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
6378 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
6379 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6380 "and pCreateInfos->basePipelineIndex is not -1.");
6381 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006382 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006383 skip |=
6384 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
6385 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
6386 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
6387 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
6388 "that element.");
6389 }
sourav parmarf4a78252020-04-10 13:04:21 -07006390 }
6391 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006392 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006393 skip |=
6394 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
6395 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6396 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
6397 "commands pCreateInfos parameter.");
6398 }
6399 } else {
6400 if (pCreateInfos[i].basePipelineIndex != -1) {
6401 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
6402 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6403 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6404 }
6405 }
6406 }
6407 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
6408 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
6409 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
6410 }
6411 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
6412 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
6413 "vkCreateRayTracingPipelinesNV: flags must not include "
6414 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
6415 }
6416 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
6417 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
6418 "vkCreateRayTracingPipelinesNV: flags must not include "
6419 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
6420 }
6421 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
6422 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
6423 "vkCreateRayTracingPipelinesNV: flags must not include "
6424 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
6425 }
6426 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
6427 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
6428 "vkCreateRayTracingPipelinesNV: flags must not include "
6429 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
6430 }
6431 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6432 skip |= LogError(
6433 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
6434 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6435 }
6436 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6437 skip |= LogError(
6438 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
6439 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
6440 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006441 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
6442 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
6443 "vkCreateRayTracingPipelinesNV: flags must not include "
6444 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6445 }
6446 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6447 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
6448 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
6449 }
ziga-lunargdfffee42021-10-10 11:49:59 +02006450 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
6451 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
6452 "vkCreateRayTracingPipelinesNV: flags must not contain the "
6453 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
6454 }
Peter Chen85366392019-05-14 15:20:11 -04006455 }
6456
6457 return skip;
6458}
6459
sourav parmarcd5fb182020-07-17 12:58:44 -07006460bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
6461 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
6462 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006463 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006464 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006465 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
6466 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
6467 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006468 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006469 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006470 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6471 std::stringstream msg;
6472 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6473 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
aitor-lunargdbd9e652022-02-23 19:12:53 +01006474 &pCreateInfos[i].pStages[stage_index]);
ziga-lunargc6341372021-07-28 12:57:42 +02006475 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006476 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
6477 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6478 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
6479 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6480 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6481 }
6482 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6483 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
6484 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6485 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
6486 }
6487 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006488 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006489 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06006490 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineStageCreationFeedbackCount-06652",
sourav parmarcd5fb182020-07-17 12:58:44 -07006491 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
6492 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
6493 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006494 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
6495 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
6496 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006497 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006498 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006499 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6500 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6501 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6502 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07006503 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07006504 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6505 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6506 }
6507 }
sourav parmarf4a78252020-04-10 13:04:21 -07006508 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006509 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
6510 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07006511 }
6512 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006513 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07006514 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07006515 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
6516 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006517 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006518 }
6519 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6520 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
6521 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07006522 }
6523 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
6524 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
6525 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
6526 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
6527 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
6528 skip |= LogError(
6529 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07006530 "vkCreateRayTracingPipelinesKHR: If flags includes "
6531 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006532 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6533 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
6534 "must not be VK_SHADER_UNUSED_KHR");
6535 }
6536 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
6537 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
6538 skip |= LogError(
6539 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07006540 "vkCreateRayTracingPipelinesKHR: If flags includes "
6541 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006542 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6543 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
6544 "element must not be VK_SHADER_UNUSED_KHR");
6545 }
6546 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006547 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
6548 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
6549 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
6550 skip |= LogError(
6551 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
6552 "vkCreateRayTracingPipelinesKHR: If "
6553 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
6554 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
6555 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6556 }
6557 }
sourav parmarf4a78252020-04-10 13:04:21 -07006558 }
6559 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6560 if (pCreateInfos[i].basePipelineIndex != -1) {
6561 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6562 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07006563 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07006564 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6565 "and pCreateInfos->basePipelineIndex is not -1.");
6566 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006567 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006568 skip |=
6569 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
6570 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
6571 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
6572 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
6573 "element.");
6574 }
sourav parmarf4a78252020-04-10 13:04:21 -07006575 }
6576 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006577 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006578 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07006579 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006580 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
6581 ") must be a valid into the calling"
6582 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07006583 pCreateInfos[i].basePipelineIndex, createInfoCount);
6584 }
6585 } else {
6586 if (pCreateInfos[i].basePipelineIndex != -1) {
6587 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07006588 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07006589 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6590 }
6591 }
6592 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006593 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
6594 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
6595 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
6596 "vkCreateRayTracingPipelinesKHR: If flags includes "
6597 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
6598 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006599 }
6600 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
6601 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
6602 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
6603 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
6604 "pLibraryInfo and pLibraryInterface must be NULL.");
6605 }
6606 if (pCreateInfos[i].pLibraryInfo) {
6607 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
6608 if (pCreateInfos[i].stageCount == 0) {
6609 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
6610 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6611 "stageCount must not be 0.");
6612 }
6613 if (pCreateInfos[i].groupCount == 0) {
6614 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
6615 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6616 "groupCount must not be 0.");
6617 }
6618 } else {
6619 if (pCreateInfos[i].pLibraryInterface == NULL) {
6620 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
6621 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6622 "is greater than 0, its "
6623 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006624 }
6625 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006626 }
6627 if (pCreateInfos[i].pLibraryInterface) {
6628 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6629 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6630 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6631 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6632 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6633 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006634 }
6635 if (deferredOperation != VK_NULL_HANDLE) {
6636 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6637 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6638 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6639 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006640 }
6641 }
ziga-lunargdea76582021-09-17 14:38:08 +02006642 if (pCreateInfos[i].pDynamicState) {
6643 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6644 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6645 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6646 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6647 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6648 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6649 }
6650 }
6651 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006652 }
6653
6654 return skip;
6655}
6656
Mike Schuchardt21638df2019-03-16 10:52:02 -07006657#ifdef VK_USE_PLATFORM_WIN32_KHR
6658bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6659 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006660 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006661 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006662 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006663 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006664 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006665 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006666 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006667 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006668 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006669 skip |=
6670 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006671 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006672 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6673 skip |= validate_struct_type(
6674 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6675 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6676 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6677 if (pSurfaceInfo != NULL) {
6678 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6679 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6680 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6681
6682 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6683 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6684 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6685 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006686 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6687 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006688
Mike Schuchardt05b028d2022-01-05 14:15:00 -08006689 if (pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
6690 skip |= LogError(device, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
6691 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
6692 "VK_GOOGLE_surfaceless_query is not enabled.");
6693 }
6694
Mike Schuchardt21638df2019-03-16 10:52:02 -07006695 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6696 }
6697 return skip;
6698}
6699#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006700
6701bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6702 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006703 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006704 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6705 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006706 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006707 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6708 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6709 }
6710 return skip;
6711}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006712
6713bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006714 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006715 bool skip = false;
6716
6717 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006718 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006719 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006720 }
6721
6722 return skip;
6723}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006724
6725bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006726 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006727 bool skip = false;
6728
6729 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006730 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6731 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006732 }
6733
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006734 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006735 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006736 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6737 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006738 }
6739
6740 return skip;
6741}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006742
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006743bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6744 uint32_t bindingCount, const VkBuffer *pBuffers,
6745 const VkDeviceSize *pOffsets) const {
6746 bool skip = false;
6747 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006748 skip |=
6749 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6750 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6751 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006752 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6753 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006754 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6755 ") must be less than "
6756 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006757 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6758 }
6759
Jeff Bolz165818a2020-05-08 11:19:03 -05006760 for (uint32_t i = 0; i < bindingCount; ++i) {
6761 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006762 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006763 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006764 skip |=
6765 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6766 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006767 } else {
6768 if (pOffsets[i] != 0) {
6769 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006770 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6771 "] is not 0",
6772 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006773 }
6774 }
6775 }
6776 }
6777
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006778 return skip;
6779}
6780
Mark Lobodzinski84988402019-09-11 15:27:30 -06006781bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006782 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006783 bool skip = false;
6784 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006785 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6786 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006787 }
6788 return skip;
6789}
6790
6791bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006792 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006793 bool skip = false;
6794 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006795 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6796 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006797 }
6798 return skip;
6799}
Petr Kraus3d720392019-11-13 02:52:39 +01006800
6801bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6802 VkSemaphore semaphore, VkFence fence,
6803 uint32_t *pImageIndex) const {
6804 bool skip = false;
6805
6806 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006807 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6808 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006809 }
6810
6811 return skip;
6812}
6813
6814bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6815 uint32_t *pImageIndex) const {
6816 bool skip = false;
6817
6818 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006819 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6820 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006821 }
6822
6823 return skip;
6824}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006825
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006826bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6827 uint32_t firstBinding, uint32_t bindingCount,
6828 const VkBuffer *pBuffers,
6829 const VkDeviceSize *pOffsets,
6830 const VkDeviceSize *pSizes) const {
6831 bool skip = false;
6832
6833 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6834 for (uint32_t i = 0; i < bindingCount; ++i) {
6835 if (pOffsets[i] & 3) {
6836 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6837 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6838 }
6839 }
6840
6841 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6842 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6843 "%s: The firstBinding(%" PRIu32
6844 ") index is greater than or equal to "
6845 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6846 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6847 }
6848
6849 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6850 skip |=
6851 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6852 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6853 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6854 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6855 }
6856
6857 for (uint32_t i = 0; i < bindingCount; ++i) {
6858 // pSizes is optional and may be nullptr.
6859 if (pSizes != nullptr) {
6860 if (pSizes[i] != VK_WHOLE_SIZE &&
6861 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6862 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6863 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6864 ") is not VK_WHOLE_SIZE and is greater than "
6865 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6866 cmd_name, i, pSizes[i]);
6867 }
6868 }
6869 }
6870
6871 return skip;
6872}
6873
6874bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6875 uint32_t firstCounterBuffer,
6876 uint32_t counterBufferCount,
6877 const VkBuffer *pCounterBuffers,
6878 const VkDeviceSize *pCounterBufferOffsets) const {
6879 bool skip = false;
6880
6881 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6882 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6883 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6884 "%s: The firstCounterBuffer(%" PRIu32
6885 ") index is greater than or equal to "
6886 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6887 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6888 }
6889
6890 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6891 skip |=
6892 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6893 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6894 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6895 cmd_name, firstCounterBuffer, counterBufferCount,
6896 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6897 }
6898
6899 return skip;
6900}
6901
6902bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6903 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6904 const VkBuffer *pCounterBuffers,
6905 const VkDeviceSize *pCounterBufferOffsets) const {
6906 bool skip = false;
6907
6908 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6909 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6910 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6911 "%s: The firstCounterBuffer(%" PRIu32
6912 ") index is greater than or equal to "
6913 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6914 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6915 }
6916
6917 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6918 skip |=
6919 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6920 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6921 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6922 cmd_name, firstCounterBuffer, counterBufferCount,
6923 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6924 }
6925
6926 return skip;
6927}
6928
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006929bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6930 uint32_t firstInstance, VkBuffer counterBuffer,
6931 VkDeviceSize counterBufferOffset,
6932 uint32_t counterOffset, uint32_t vertexStride) const {
6933 bool skip = false;
6934
6935 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006936 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6937 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6938 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6939 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006940 }
6941
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006942 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006943 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006944 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006945 }
6946
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006947 return skip;
6948}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006949
6950bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6951 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6952 const VkAllocationCallbacks *pAllocator,
6953 VkSamplerYcbcrConversion *pYcbcrConversion,
6954 const char *apiName) const {
6955 bool skip = false;
6956
6957 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006958 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006959 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006960 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006961 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6962 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006963 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006964 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006965 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006966
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006967#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006968 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006969 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006970#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006971 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006972#endif
6973
sfricke-samsung1a72f942020-07-25 12:09:18 -07006974 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006975
6976 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006977 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006978 const VkComponentMapping components = pCreateInfo->components;
6979 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6980 if (FormatIsXChromaSubsampled(format) == true) {
6981 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6982 skip |=
6983 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006984 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6985 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006986 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006987 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006988
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006989 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6990 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6991 skip |= LogError(
6992 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6993 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6994 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6995 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6996 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006997
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006998 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6999 (components.r != VK_COMPONENT_SWIZZLE_B)) {
7000 skip |=
7001 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07007002 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
7003 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07007004 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007005 }
sfricke-samsung83d98122020-07-04 06:21:15 -07007006
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007007 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
7008 (components.b != VK_COMPONENT_SWIZZLE_R)) {
7009 skip |=
7010 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07007011 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
7012 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07007013 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007014 }
sfricke-samsung83d98122020-07-04 06:21:15 -07007015
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007016 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007017 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
7018 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
7019 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007020 skip |=
7021 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07007022 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
7023 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07007024 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
7025 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007026 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07007027 }
7028
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007029 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
7030 // Checks same VU multiple ways in order to give a more useful error message
7031 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
7032 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
7033 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
7034 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
7035 skip |= LogError(
7036 device, vuid,
7037 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
7038 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
7039 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
7040 string_VkComponentSwizzle(components.b));
7041 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07007042
sfricke-samsunged028b02021-09-06 23:14:51 -07007043 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
7044 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007045 // 3 = no [a]
7046 // 2 = no [b,a]
7047 // 1 = no [g,b,a]
7048 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07007049 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007050
sfricke-samsunged028b02021-09-06 23:14:51 -07007051 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
7052 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007053 skip |= LogError(device, vuid,
7054 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
7055 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
7056 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
7057 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07007058 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007059 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
7060 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
7061 skip |= LogError(device, vuid,
7062 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
7063 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
7064 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
7065 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
7066 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07007067 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02007068 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
7069 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
7070 skip |= LogError(device, vuid,
7071 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
7072 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
7073 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
7074 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
7075 string_VkComponentSwizzle(components.b));
7076 }
sfricke-samsung83d98122020-07-04 06:21:15 -07007077 }
7078 }
7079
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08007080 return skip;
7081}
7082
7083bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
7084 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
7085 const VkAllocationCallbacks *pAllocator,
7086 VkSamplerYcbcrConversion *pYcbcrConversion) const {
7087 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
7088 "vkCreateSamplerYcbcrConversion");
7089}
7090
7091bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
7092 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
7093 VkSamplerYcbcrConversion *pYcbcrConversion) const {
7094 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
7095 "vkCreateSamplerYcbcrConversionKHR");
7096}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08007097
7098bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
7099 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
7100 bool skip = false;
7101 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
7102 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
7103
7104 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07007105 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
7106 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
7107 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
7108 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
7109 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08007110 }
7111 return skip;
7112}
sourav parmara96ab1a2020-04-25 16:28:23 -07007113
7114bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007115 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07007116 bool skip = false;
7117 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
7118 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
7119 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
7120 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007121 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007122 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
7123 skip |= LogError(
7124 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
7125 "vkCopyAccelerationStructureToMemoryKHR: The "
7126 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
7127 }
7128 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
7129 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
7130 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
7131 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
7132 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
7133 }
sourav parmara96ab1a2020-04-25 16:28:23 -07007134 return skip;
7135}
7136
7137bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
7138 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
7139 bool skip = false;
7140 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
7141 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
7142 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
7143 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
7144 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007145 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
7146 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007147 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07007148 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07007149 }
sourav parmara96ab1a2020-04-25 16:28:23 -07007150 return skip;
7151}
7152
7153bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
7154 const char *api_name) const {
7155 bool skip = false;
7156 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
7157 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
7158 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
7159 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
7160 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
7161 api_name);
7162 }
7163 return skip;
7164}
7165
7166bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007167 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07007168 bool skip = false;
7169 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007170 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007171 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07007172 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07007173 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
7174 "vkCopyAccelerationStructureKHR: The "
7175 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007176 }
sourav parmara96ab1a2020-04-25 16:28:23 -07007177 return skip;
7178}
7179
7180bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
7181 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
7182 bool skip = false;
7183 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
7184 return skip;
7185}
7186
7187bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06007188 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07007189 bool skip = false;
7190 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007191 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07007192 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
7193 }
7194 return skip;
7195}
7196
7197bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007198 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07007199 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07007200 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007201 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007202 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
7203 skip |= LogError(
7204 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
7205 "vkCopyMemoryToAccelerationStructureKHR: The "
7206 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007207 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007208 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
7209 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07007210 return skip;
7211}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06007212
sourav parmara96ab1a2020-04-25 16:28:23 -07007213bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
7214 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
7215 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07007216 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07007217 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
7218 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007219 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07007220 pInfo->src.deviceAddress);
7221 }
sourav parmar83c31b12020-05-06 12:30:54 -07007222 return skip;
7223}
7224bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
7225 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
7226 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
7227 bool skip = false;
7228 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
7229 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
sfricke-samsungf91881c2022-03-31 01:12:00 -05007230 if (!IsExtEnabled(device_extensions.vk_khr_ray_tracing_maintenance1)) {
7231 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
7232 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7233 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7234 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7235 } else if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR ||
7236 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR)) {
7237 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-06742",
7238 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7239 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR or "
7240 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR or "
7241 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7242 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7243 }
sourav parmar83c31b12020-05-06 12:30:54 -07007244 }
7245 return skip;
7246}
7247bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
7248 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
7249 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
7250 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007251 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007252 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7253 skip |= LogError(
7254 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
7255 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
7256 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
7257 }
sourav parmar83c31b12020-05-06 12:30:54 -07007258 if (dataSize < accelerationStructureCount * stride) {
7259 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
7260 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007261 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07007262 dataSize, accelerationStructureCount, stride);
7263 }
sfricke-samsungf91881c2022-03-31 01:12:00 -05007264
sourav parmar83c31b12020-05-06 12:30:54 -07007265 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
7266 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
sfricke-samsungf91881c2022-03-31 01:12:00 -05007267 if (!IsExtEnabled(device_extensions.vk_khr_ray_tracing_maintenance1)) {
7268 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
7269 "vkWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7270 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7271 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7272 } else if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR ||
7273 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR)) {
7274 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06742",
7275 "vkWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7276 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR or "
7277 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR or "
7278 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7279 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7280 }
sourav parmar83c31b12020-05-06 12:30:54 -07007281 }
sfricke-samsungf91881c2022-03-31 01:12:00 -05007282
7283 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
7284 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07007285 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
7286 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7287 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
7288 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7289 stride);
sfricke-samsungf91881c2022-03-31 01:12:00 -05007290 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07007291 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
7292 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7293 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
7294 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7295 stride);
sfricke-samsungf91881c2022-03-31 01:12:00 -05007296 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR) {
7297 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06731",
7298 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7299 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR,"
7300 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7301 stride);
7302 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR) {
7303 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06733",
7304 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7305 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR,"
7306 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7307 stride);
sourav parmar83c31b12020-05-06 12:30:54 -07007308 }
7309 }
sourav parmar83c31b12020-05-06 12:30:54 -07007310 return skip;
7311}
7312bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
7313 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
7314 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007315 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007316 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
7317 skip |= LogError(
7318 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
7319 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
7320 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07007321 }
7322 return skip;
7323}
7324
7325bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07007326 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7327 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
7328 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7329 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07007330 uint32_t width, uint32_t height, uint32_t depth) const {
7331 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07007332 // RayGen
7333 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7334 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
7335 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007336 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007337 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7338 0) {
7339 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
7340 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7341 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7342 }
7343 // Callable
7344 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7345 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
7346 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7347 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007348 }
7349 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7350 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
7351 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007352 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7353 }
7354 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7355 0) {
7356 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
7357 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7358 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007359 }
7360 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007361 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7362 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
7363 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7364 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007365 }
7366 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7367 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007368 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
7369 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07007370 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007371 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7372 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
7373 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7374 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7375 }
sourav parmar83c31b12020-05-06 12:30:54 -07007376 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007377 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7378 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
7379 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
7380 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07007381 }
7382 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7383 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
7384 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007385 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7386 }
7387 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7388 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
7389 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7390 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7391 }
7392 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
Mike Schuchardt840f1252022-05-11 11:31:25 -07007393 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03641",
sourav parmarcd5fb182020-07-17 12:58:44 -07007394 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
7395 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
7396 }
7397 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
7398 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007399 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03638",
sourav parmarcd5fb182020-07-17 12:58:44 -07007400 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
7401 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07007402 }
7403
sourav parmarcd5fb182020-07-17 12:58:44 -07007404 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
7405 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007406 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03639",
sourav parmarcd5fb182020-07-17 12:58:44 -07007407 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
7408 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
7409 }
7410
7411 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
7412 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007413 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03640",
sourav parmarcd5fb182020-07-17 12:58:44 -07007414 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
7415 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07007416 }
7417 return skip;
7418}
7419
sourav parmarcd5fb182020-07-17 12:58:44 -07007420bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
7421 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7422 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7423 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007424 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007425 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007426 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7427 skip |= LogError(
7428 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
7429 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7430 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007431 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007432 // RayGen
7433 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7434 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
7435 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007436 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007437 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7438 0) {
7439 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
7440 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7441 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7442 }
7443 // Callabe
7444 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7445 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
7446 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7447 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007448 }
7449 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7450 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07007451 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
7452 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7453 }
7454 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7455 0) {
7456 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
7457 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7458 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007459 }
7460 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007461 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7462 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
7463 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7464 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007465 }
7466 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7467 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007468 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
7469 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07007470 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007471 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7472 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
7473 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7474 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7475 }
sourav parmar83c31b12020-05-06 12:30:54 -07007476 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007477 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7478 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
7479 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
7480 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007481 }
7482 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7483 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07007484 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
7485 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7486 }
7487 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7488 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
7489 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7490 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007491 }
7492
sourav parmarcd5fb182020-07-17 12:58:44 -07007493 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7494 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
7495 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07007496 }
7497 return skip;
7498}
sfricke-samsungf91881c2022-03-31 01:12:00 -05007499
7500bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirect2KHR(VkCommandBuffer commandBuffer,
7501 VkDeviceAddress indirectDeviceAddress) const {
7502 bool skip = false;
7503 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7504 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7505 skip |= LogError(
Mike Schuchardtac73fbe2022-05-24 10:37:52 -07007506 device, "VUID-vkCmdTraceRaysIndirect2KHR-rayTracingPipelineTraceRaysIndirect2-03637",
sfricke-samsungf91881c2022-03-31 01:12:00 -05007507 "vkCmdTraceRaysIndirect2KHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7508 "feature must be enabled.");
7509 }
7510
7511 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7512 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirect2KHR-indirectDeviceAddress-03634",
7513 "vkCmdTraceRaysIndirect2KHR: indirectDeviceAddress must be a multiple of 4.");
7514 }
7515 return skip;
7516}
7517
sourav parmar83c31b12020-05-06 12:30:54 -07007518bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
7519 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
7520 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
7521 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
7522 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
7523 uint32_t width, uint32_t height, uint32_t depth) const {
7524 bool skip = false;
7525 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7526 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
7527 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
7528 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7529 }
7530 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7531 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
7532 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
7533 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7534 }
7535 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7536 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
7537 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
7538 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
7539 }
7540
7541 // hitShader
7542 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7543 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
7544 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
7545 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7546 }
7547 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7548 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
7549 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
7550 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7551 }
7552 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7553 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
7554 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
7555 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7556 }
7557
7558 // missShader
7559 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7560 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
7561 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
7562 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7563 }
7564 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7565 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
7566 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
7567 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7568 }
7569 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7570 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
7571 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
7572 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7573 }
7574
7575 // raygenShader
7576 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7577 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
7578 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07007579 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7580 }
7581 if (width > device_limits.maxComputeWorkGroupCount[0]) {
7582 skip |=
7583 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
7584 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
7585 }
7586 if (height > device_limits.maxComputeWorkGroupCount[1]) {
7587 skip |=
7588 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
7589 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
7590 }
7591 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
7592 skip |=
7593 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
7594 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07007595 }
7596 return skip;
7597}
7598
sourav parmar83c31b12020-05-06 12:30:54 -07007599bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007600 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
7601 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007602 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007603 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
7604 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007605 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
7606 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007607 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07007608 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
7609 }
7610 return skip;
7611}
7612
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007613bool StatelessValidation::ValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7614 const VkViewport *pViewports, bool is_ext) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007615 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007616 const char *api_call = is_ext ? "vkCmdSetViewportWithCountEXT" : "vkCmdSetViewportWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007617
7618 if (!physical_device_features.multiViewport) {
7619 if (viewportCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007620 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03395",
7621 "%s: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", api_call,
Piers Daniell39842ee2020-07-10 16:42:33 -06007622 viewportCount);
7623 }
7624 } else { // multiViewport enabled
7625 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007626 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03394",
7627 "%s: viewportCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007628 ") must "
7629 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007630 api_call, viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007631 }
7632 }
7633
7634 if (pViewports) {
7635 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
7636 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Piers Daniell39842ee2020-07-10 16:42:33 -06007637 skip |= manual_PreCallValidateViewport(
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007638 viewport, api_call, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Piers Daniell39842ee2020-07-10 16:42:33 -06007639 }
7640 }
7641
7642 return skip;
7643}
7644
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007645bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7646 const VkViewport *pViewports) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007647 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007648 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, true);
7649 return skip;
7650}
7651
7652bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7653 const VkViewport *pViewports) const {
7654 bool skip = false;
7655 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, false);
7656 return skip;
7657}
7658
7659bool StatelessValidation::ValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7660 const VkRect2D *pScissors, bool is_ext) const {
7661 bool skip = false;
7662 const char *api_call = is_ext ? "vkCmdSetScissorWithCountEXT" : "vkCmdSetScissorWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007663
7664 if (!physical_device_features.multiViewport) {
7665 if (scissorCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007666 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03398",
7667 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007668 ") must "
7669 "be 1 when the multiViewport feature is disabled.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007670 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007671 }
7672 } else { // multiViewport enabled
7673 if (scissorCount == 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007674 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7675 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007676 ") must "
7677 "be great than zero.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007678 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007679 } else if (scissorCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007680 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7681 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007682 ") must "
7683 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007684 api_call, scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007685 }
7686 }
7687
7688 if (pScissors) {
7689 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
7690 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
7691
7692 if (scissor.offset.x < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007693 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", api_call,
7694 scissor_i, scissor.offset.x);
Piers Daniell39842ee2020-07-10 16:42:33 -06007695 }
7696
7697 if (scissor.offset.y < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007698 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", api_call,
7699 scissor_i, scissor.offset.y);
Piers Daniell39842ee2020-07-10 16:42:33 -06007700 }
7701
7702 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7703 if (x_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007704 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03400",
7705 "%s: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7706 "] will overflow int32_t.",
7707 api_call, scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007708 }
7709
7710 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7711 if (y_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007712 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03401",
7713 "%s: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7714 "] will overflow int32_t.",
7715 api_call, scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7716 }
7717 }
7718 }
7719
7720 return skip;
7721}
7722
7723bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7724 const VkRect2D *pScissors) const {
7725 bool skip = false;
7726 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, true);
7727 return skip;
7728}
7729
7730bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7731 const VkRect2D *pScissors) const {
7732 bool skip = false;
7733 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, false);
7734 return skip;
7735}
7736
7737bool StatelessValidation::ValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount,
7738 const VkBuffer *pBuffers, const VkDeviceSize *pOffsets,
7739 const VkDeviceSize *pSizes, const VkDeviceSize *pStrides,
7740 bool is_2ext) const {
7741 bool skip = false;
7742 const char *api_call = is_2ext ? "vkCmdBindVertexBuffers2EXT()" : "vkCmdBindVertexBuffers2()";
7743 if (firstBinding >= device_limits.maxVertexInputBindings) {
7744 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03355",
7745 "%s firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")", api_call,
7746 firstBinding, device_limits.maxVertexInputBindings);
7747 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7748 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03356",
7749 "%s sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7750 ") must be less than "
7751 "maxVertexInputBindings (%" PRIu32 ")",
7752 api_call, firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7753 }
7754
7755 for (uint32_t i = 0; i < bindingCount; ++i) {
7756 if (pBuffers[i] == VK_NULL_HANDLE) {
7757 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
7758 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
7759 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04111",
7760 "%s required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", api_call, i);
7761 } else {
7762 if (pOffsets[i] != 0) {
7763 skip |=
7764 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04112",
7765 "%s pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32 "] is not 0", api_call, i, i);
7766 }
7767 }
7768 }
7769 if (pStrides) {
7770 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
7771 skip |=
7772 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pStrides-03362",
7773 "%s pStrides[%" PRIu32 "] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7774 api_call, i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007775 }
7776 }
7777 }
7778
7779 return skip;
7780}
7781
7782bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7783 uint32_t bindingCount, const VkBuffer *pBuffers,
7784 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7785 const VkDeviceSize *pStrides) const {
7786 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007787 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, true);
7788 return skip;
7789}
Piers Daniell39842ee2020-07-10 16:42:33 -06007790
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007791bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7792 uint32_t bindingCount, const VkBuffer *pBuffers,
7793 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7794 const VkDeviceSize *pStrides) const {
7795 bool skip = false;
7796 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, false);
Piers Daniell39842ee2020-07-10 16:42:33 -06007797 return skip;
7798}
sourav parmarcd5fb182020-07-17 12:58:44 -07007799
7800bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7801 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7802 bool skip = false;
7803 for (uint32_t i = 0; i < infoCount; ++i) {
7804 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7805 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7806 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7807 }
7808 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7809 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7810 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7811 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7812 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7813 api_name);
7814 }
7815 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7816 skip |=
7817 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7818 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7819 }
7820 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7821 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7822 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
7823 }
7824 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
7825 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
7826 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
7827 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
7828 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
7829 api_name);
7830 }
7831 if (pInfos[i].pGeometries) {
7832 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7833 skip |= validate_ranged_enum(
7834 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
7835 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
7836 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7837 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007838 skip |= validate_struct_type(
7839 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
7840 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7841 &(pInfos[i].pGeometries[j].geometry.triangles),
7842 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7843 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7844 skip |= validate_struct_pnext(
7845 api_name,
7846 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7847 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7848 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7849 skip |=
7850 validate_ranged_enum(api_name,
7851 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
7852 ParameterName::IndexVector{i, j}),
7853 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
7854 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7855 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7856 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7857 &pInfos[i].pGeometries[j].geometry.triangles,
7858 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7859 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7860 skip |= validate_ranged_enum(
7861 api_name,
7862 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
7863 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
7864 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7865
7866 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
7867 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7868 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7869 }
7870 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7871 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7872 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7873 skip |=
7874 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7875 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7876 api_name);
7877 }
7878 }
7879 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7880 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7881 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7882 &pInfos[i].pGeometries[j].geometry.instances,
7883 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7884 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7885 skip |= validate_struct_type(
7886 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
7887 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7888 &(pInfos[i].pGeometries[j].geometry.instances),
7889 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7890 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7891 skip |= validate_struct_pnext(
7892 api_name,
7893 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7894 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7895 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7896
7897 skip |= validate_bool32(api_name,
7898 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
7899 ParameterName::IndexVector{i, j}),
7900 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
7901 }
7902 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7903 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7904 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7905 &pInfos[i].pGeometries[j].geometry.aabbs,
7906 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7907 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7908 skip |= validate_struct_type(
7909 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
7910 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7911 &(pInfos[i].pGeometries[j].geometry.aabbs),
7912 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7913 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7914 skip |= validate_struct_pnext(
7915 api_name,
7916 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7917 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7918 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7919 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
7920 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7921 "(%s):stride must be less than or equal to 2^32-1", api_name);
7922 }
7923 }
7924 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7925 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7926 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7927 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7928 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7929 api_name);
7930 }
7931 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7932 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7933 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7934 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7935 "of elements of"
7936 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7937 api_name);
7938 }
7939 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
7940 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7941 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7942 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7943 api_name);
7944 }
7945 }
7946 }
7947 }
7948 if (pInfos[i].ppGeometries != NULL) {
7949 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7950 skip |= validate_ranged_enum(
7951 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
7952 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
7953 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7954 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007955 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7956 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7957 &pInfos[i].ppGeometries[j]->geometry.triangles,
7958 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7959 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7960 skip |= validate_struct_type(
7961 api_name,
7962 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
7963 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7964 &(pInfos[i].ppGeometries[j]->geometry.triangles),
7965 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7966 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7967 skip |= validate_struct_pnext(
7968 api_name,
7969 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7970 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7971 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7972 skip |= validate_ranged_enum(api_name,
7973 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
7974 ParameterName::IndexVector{i, j}),
7975 "VkFormat", AllVkFormatEnums,
7976 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
7977 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7978 skip |= validate_ranged_enum(api_name,
7979 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
7980 ParameterName::IndexVector{i, j}),
7981 "VkIndexType", AllVkIndexTypeEnums,
7982 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7983 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7984 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7985 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7986 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7987 }
7988 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7989 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7990 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7991 skip |=
7992 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7993 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7994 api_name);
7995 }
7996 }
7997 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7998 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7999 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
8000 &pInfos[i].ppGeometries[j]->geometry.instances,
8001 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
8002 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
8003 skip |= validate_struct_type(
8004 api_name,
8005 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
8006 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
8007 &(pInfos[i].ppGeometries[j]->geometry.instances),
8008 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
8009 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
8010 skip |= validate_struct_pnext(
8011 api_name,
8012 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
8013 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
8014 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
8015 skip |= validate_bool32(api_name,
8016 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
8017 ParameterName::IndexVector{i, j}),
8018 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
8019 }
8020 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8021 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
8022 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
8023 &pInfos[i].ppGeometries[j]->geometry.aabbs,
8024 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
8025 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
8026 skip |= validate_struct_type(
8027 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
8028 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
8029 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
8030 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
8031 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
8032 skip |= validate_struct_pnext(
8033 api_name,
8034 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
8035 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
8036 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
8037 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
8038 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
8039 "(%s):stride must be less than or equal to 2^32-1", api_name);
8040 }
8041 }
8042 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
8043 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8044 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
8045 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
8046 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
8047 api_name);
8048 }
8049 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
8050 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8051 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
8052 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
8053 "of elements of"
8054 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
8055 api_name);
8056 }
8057 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
8058 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
8059 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
8060 " member of each geometry in either pGeometries or ppGeometries must be the same.",
8061 api_name);
8062 }
8063 }
8064 }
8065 }
8066 }
8067 return skip;
8068}
8069bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
8070 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
8071 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
8072 bool skip = false;
8073 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
8074 for (uint32_t i = 0; i < infoCount; ++i) {
8075 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
8076 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
8077 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
8078 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
8079 "scratchData.deviceAddress member must be a multiple of "
8080 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
8081 }
8082 for (uint32_t k = 0; k < infoCount; ++k) {
8083 if (i == k) continue;
8084 bool found = false;
8085 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008086 skip |=
8087 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
8088 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
8089 ") of pInfos must "
8090 "not be "
8091 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8092 ") of pInfos.",
8093 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07008094 found = true;
8095 }
8096 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008097 skip |=
8098 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
8099 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
8100 ") of pInfos must "
8101 "not be "
8102 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8103 ") of pInfos.",
8104 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07008105 found = true;
8106 }
8107 if (found) break;
8108 }
8109 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
8110 if (pInfos[i].pGeometries) {
8111 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8112 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
8113 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8114 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
8115 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
8116 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8117 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8118 }
8119 } else {
8120 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
8121 skip |=
8122 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
8123 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
8124 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8125 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8126 }
8127 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01008128 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008129 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8130 skip |= LogError(
8131 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
8132 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
8133 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8134 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01008135 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8136 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008137 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
8138 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
8139 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8140 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8141 }
8142 }
8143 } else if (pInfos[i].ppGeometries) {
8144 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8145 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
8146 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8147 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
8148 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
8149 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8150 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8151 }
8152 } else {
8153 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
8154 skip |=
8155 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
8156 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
8157 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8158 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8159 }
8160 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01008161 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008162 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8163 skip |= LogError(
8164 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
8165 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
8166 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8167 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01008168 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8169 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008170 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
8171 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
8172 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8173 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8174 }
8175 }
8176 }
8177 }
8178 }
8179 return skip;
8180}
8181
8182bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
8183 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
8184 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
8185 const uint32_t *const *ppMaxPrimitiveCounts) const {
8186 bool skip = false;
8187 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
8188 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008189 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07008190 if (!ray_tracing_acceleration_structure_features ||
8191 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
8192 skip |= LogError(
8193 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
8194 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
8195 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
8196 }
8197 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008198 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
8199 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
8200 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
8201 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
8202 "scratchData.deviceAddress member must be a multiple of "
8203 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
8204 }
8205 for (uint32_t k = 0; k < infoCount; ++k) {
8206 if (i == k) continue;
8207 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008208 skip |= LogError(
8209 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
8210 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
8211 ") "
8212 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
8213 "any other element [%" PRIu32 ") of pInfos.",
8214 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07008215 break;
8216 }
8217 }
8218 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
8219 if (pInfos[i].pGeometries) {
8220 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8221 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
8222 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8223 skip |= LogError(
8224 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
8225 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8226 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8227 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8228 }
8229 } else {
8230 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
8231 skip |= LogError(
8232 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
8233 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8234 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8235 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8236 }
8237 }
8238 }
8239 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8240 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8241 skip |= LogError(
8242 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
8243 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8244 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8245 }
8246 }
8247 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8248 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
8249 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
8250 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
8251 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8252 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8253 }
8254 }
8255 } else if (pInfos[i].ppGeometries) {
8256 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8257 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
8258 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8259 skip |= LogError(
8260 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
8261 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8262 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8263 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8264 }
8265 } else {
8266 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
8267 skip |= LogError(
8268 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
8269 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8270 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8271 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8272 }
8273 }
8274 }
8275 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8276 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8277 skip |= LogError(
8278 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
8279 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8280 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8281 }
8282 }
8283 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8284 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
8285 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
8286 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
8287 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8288 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8289 }
8290 }
8291 }
8292 }
8293 }
8294 return skip;
8295}
8296
8297bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
8298 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
8299 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
8300 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
8301 bool skip = false;
8302 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
8303 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008304 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07008305 if (!ray_tracing_acceleration_structure_features ||
8306 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
8307 skip |=
8308 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
8309 "vkBuildAccelerationStructuresKHR: The "
8310 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
8311 }
8312 for (uint32_t i = 0; i < infoCount; ++i) {
8313 for (uint32_t j = 0; j < infoCount; ++j) {
8314 if (i == j) continue;
8315 bool found = false;
8316 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008317 skip |=
8318 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
8319 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
8320 ") of pInfos must "
8321 "not be "
8322 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8323 ") of pInfos.",
8324 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008325 found = true;
8326 }
8327 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008328 skip |=
8329 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
8330 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
8331 ") of pInfos must "
8332 "not be "
8333 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8334 ") of pInfos.",
8335 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008336 found = true;
8337 }
8338 if (found) break;
8339 }
8340 }
8341 return skip;
8342}
8343
8344bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
8345 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
8346 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
8347 bool skip = false;
8348 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
8349 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008350 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
8351 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
ziga-lunargbcfba982022-03-19 17:49:55 +01008352 if (!((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_TRUE) ||
8353 (ray_query_features && ray_query_features->rayQuery == VK_TRUE))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008354 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
Lars-Ivar Hesselberg Simonsendcd1e402021-11-23 17:14:03 +01008355 "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled");
8356 }
8357 if (pBuildInfo != nullptr) {
8358 if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) {
8359 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619",
8360 "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts "
8361 "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values");
8362 }
sourav parmarcd5fb182020-07-17 12:58:44 -07008363 }
8364 return skip;
8365}
sfricke-samsungecafb192021-01-17 08:21:14 -08008366
Piers Daniellcb6d8032021-04-19 18:51:26 -06008367bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
8368 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
8369 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
8370 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
8371 bool skip = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06008372 const auto *vertex_attribute_divisor_features =
8373 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
8374
Piers Daniellcb6d8032021-04-19 18:51:26 -06008375 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
8376 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
8377 skip |=
8378 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
8379 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
8380 }
8381
8382 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
8383 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
8384 skip |= LogError(
8385 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
8386 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
8387 }
8388
8389 // VUID-vkCmdSetVertexInputEXT-binding-04793
8390 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
8391 bool binding_found = false;
8392 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8393 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
8394 binding_found = true;
8395 break;
8396 }
8397 }
8398 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008399 skip |= LogError(
8400 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
8401 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008402 }
8403 }
8404
8405 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
8406 if (vertexBindingDescriptionCount > 1) {
8407 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
8408 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
8409 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
8410 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
8411 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008412 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
8413 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008414 }
8415 }
8416 }
8417 }
8418
8419 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
8420 if (vertexAttributeDescriptionCount > 1) {
8421 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
8422 uint32_t location = pVertexAttributeDescriptions[attribute].location;
8423 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
8424 if (location == pVertexAttributeDescriptions[next_attribute].location) {
8425 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008426 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
8427 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008428 }
8429 }
8430 }
8431 }
8432
8433 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8434 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
8435 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008436 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
8437 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8438 "].binding is greater than maxVertexInputBindings",
8439 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008440 }
8441
8442 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
8443 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008444 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
8445 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8446 "].stride is greater than maxVertexInputBindingStride",
8447 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008448 }
8449
8450 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
8451 if (pVertexBindingDescriptions[binding].divisor == 0 &&
8452 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
8453 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008454 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8455 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008456 "vertexAttributeInstanceRateZeroDivisor is not enabled",
8457 binding);
8458 }
8459
8460 if (pVertexBindingDescriptions[binding].divisor > 1) {
8461 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
8462 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
8463 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008464 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8465 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008466 "vertexAttributeInstanceRateDivisor is not enabled",
8467 binding);
8468 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008469 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06008470 if (pVertexBindingDescriptions[binding].divisor >
8471 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008472 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
8473 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8474 "].divisor is greater than maxVertexAttribDivisor",
8475 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008476 }
8477
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008478 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06008479 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008480 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
8481 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8482 "].divisor is greater than 1 but inputRate "
8483 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
8484 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008485 }
8486 }
8487 }
8488 }
8489
8490 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008491 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06008492 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008493 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
8494 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8495 "].location is greater than maxVertexInputAttributes",
8496 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008497 }
8498
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008499 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06008500 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008501 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
8502 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8503 "].binding is greater than maxVertexInputBindings",
8504 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008505 }
8506
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008507 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06008508 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008509 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
8510 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8511 "].offset is greater than maxVertexInputAttributeOffset",
8512 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008513 }
8514
8515 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
8516 VkFormatProperties properties;
8517 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
8518 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
8519 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008520 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8521 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008522 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
8523 attribute);
8524 }
8525 }
8526
8527 return skip;
8528}
sfricke-samsung51303fb2021-05-09 19:09:13 -07008529
8530bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
8531 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
8532 const void *pValues) const {
8533 bool skip = false;
8534 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
8535 // Check that offset + size don't exceed the max.
8536 // Prevent arithetic overflow here by avoiding addition and testing in this order.
8537 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008538 skip |=
8539 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
8540 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
8541 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008542 }
8543 if (size > max_push_constants_size - offset) {
8544 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008545 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
8546 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07008547 offset, size, max_push_constants_size);
8548 }
8549
8550 // size needs to be non-zero and a multiple of 4.
8551 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008552 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
8553 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008554 }
8555
8556 // offset needs to be a multiple of 4.
8557 if ((offset & 0x3) != 0) {
8558 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008559 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008560 }
8561 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06008562}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02008563
8564bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
8565 uint32_t srcCacheCount,
8566 const VkPipelineCache *pSrcCaches) const {
8567 bool skip = false;
8568 if (pSrcCaches) {
8569 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
8570 if (pSrcCaches[index0] == dstCache) {
8571 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
8572 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
8573 report_data->FormatHandle(dstCache).c_str());
8574 break;
8575 }
8576 }
8577 }
8578 return skip;
8579}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008580
8581bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
8582 VkImageLayout imageLayout, const VkClearColorValue *pColor,
8583 uint32_t rangeCount,
8584 const VkImageSubresourceRange *pRanges) const {
8585 bool skip = false;
8586 if (!pColor) {
8587 skip |=
8588 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
8589 }
8590 return skip;
8591}
8592
8593bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
8594 const VkRenderPassBeginInfo *const rp_begin) const {
8595 bool skip = false;
8596 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
8597 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
8598 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02008599 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008600 func_name, rp_begin->clearValueCount);
8601 }
8602 return skip;
8603}
8604
8605bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8606 VkSubpassContents) const {
8607 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
8608 return skip;
8609}
8610
8611bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
8612 const VkRenderPassBeginInfo *pRenderPassBegin,
8613 const VkSubpassBeginInfo *) const {
8614 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
8615 return skip;
8616}
8617
8618bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8619 const VkSubpassBeginInfo *) const {
8620 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
8621 return skip;
8622}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02008623
8624bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
8625 uint32_t firstDiscardRectangle,
8626 uint32_t discardRectangleCount,
8627 const VkRect2D *pDiscardRectangles) const {
8628 bool skip = false;
8629
8630 if (pDiscardRectangles) {
8631 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
8632 const int64_t x_sum =
8633 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
8634 if (x_sum > std::numeric_limits<int32_t>::max()) {
8635 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
8636 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8637 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8638 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
8639 }
8640
8641 const int64_t y_sum =
8642 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
8643 if (y_sum > std::numeric_limits<int32_t>::max()) {
8644 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
8645 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8646 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8647 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
8648 }
8649 }
8650 }
8651
8652 return skip;
8653}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02008654
8655bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
8656 uint32_t queryCount, size_t dataSize, void *pData,
8657 VkDeviceSize stride, VkQueryResultFlags flags) const {
8658 bool skip = false;
8659
8660 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
8661 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
8662 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
8663 }
8664
8665 return skip;
8666}
ziga-lunargcf340c42021-08-19 00:13:38 +02008667
8668bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
8669 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
8670 bool skip = false;
8671
8672 if ((pConditionalRenderingBegin->offset & 3) != 0) {
8673 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
8674 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
8675 ") is not a multiple of 4.",
8676 pConditionalRenderingBegin->offset);
8677 }
8678
8679 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06008680}
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008681
8682bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
8683 VkSurfaceKHR surface,
8684 uint32_t *pSurfaceFormatCount,
8685 VkSurfaceFormatKHR *pSurfaceFormats) const {
8686 bool skip = false;
8687 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8688 skip |= LogError(
8689 physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06524",
8690 "vkGetPhysicalDeviceSurfaceFormatsKHR(): surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8691 }
8692 return skip;
8693}
8694
8695bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
8696 VkSurfaceKHR surface,
8697 uint32_t *pPresentModeCount,
8698 VkPresentModeKHR *pPresentModes) const {
8699 bool skip = false;
8700 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8701 skip |= LogError(
8702 physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModesKHR-surface-06524",
8703 "vkGetPhysicalDeviceSurfacePresentModesKHR: surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8704 }
8705 return skip;
8706}
8707
8708bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceCapabilities2KHR(
8709 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
8710 VkSurfaceCapabilities2KHR *pSurfaceCapabilities) const {
8711 bool skip = false;
8712 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8713 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pSurfaceInfo-06520",
8714 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8715 "VK_GOOGLE_surfaceless_query is not enabled.");
8716 }
8717 return skip;
8718}
8719
8720bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormats2KHR(
8721 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pSurfaceFormatCount,
8722 VkSurfaceFormat2KHR *pSurfaceFormats) const {
8723 bool skip = false;
8724 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8725 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormats2KHR-pSurfaceInfo-06521",
8726 "vkGetPhysicalDeviceSurfaceFormats2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8727 "VK_GOOGLE_surfaceless_query is not enabled.");
8728 }
8729 return skip;
8730}
8731
8732#ifdef VK_USE_PLATFORM_WIN32_KHR
8733bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModes2EXT(
8734 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pPresentModeCount,
8735 VkPresentModeKHR *pPresentModes) const {
8736 bool skip = false;
8737 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8738 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
8739 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8740 "VK_GOOGLE_surfaceless_query is not enabled.");
8741 }
8742 return skip;
8743}
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008744
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008745#endif // VK_USE_PLATFORM_WIN32_KHR
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008746
8747bool StatelessValidation::ValidateDeviceImageMemoryRequirements(VkDevice device, const VkDeviceImageMemoryRequirementsKHR *pInfo,
8748 const char *func_name) const {
8749 bool skip = false;
8750
8751 if (pInfo && pInfo->pCreateInfo) {
8752 const auto *image_swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pInfo->pCreateInfo);
8753 if (image_swapchain_create_info) {
8754 skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirementsKHR-pCreateInfo-06416",
8755 "%s(): pInfo->pCreateInfo->pNext chain contains VkImageSwapchainCreateInfoKHR.", func_name);
8756 }
sjfricke7f73fbd2022-05-27 06:33:36 +09008757 const auto *drm_format_modifier_create_info =
8758 LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pInfo->pCreateInfo);
8759 if (drm_format_modifier_create_info) {
Mike Schuchardt75a4db52022-06-02 14:01:11 -07008760 skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirements-pCreateInfo-06776",
sjfricke7f73fbd2022-05-27 06:33:36 +09008761 "%s(): pInfo->pCreateInfo->pNext chain contains VkImageDrmFormatModifierExplicitCreateInfoEXT.",
8762 func_name);
8763 }
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008764 }
8765
8766 return skip;
8767}
8768
8769bool StatelessValidation::manual_PreCallValidateGetDeviceImageMemoryRequirementsKHR(
8770 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, VkMemoryRequirements2 *pMemoryRequirements) const {
8771 bool skip = false;
8772
8773 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageMemoryRequirementsKHR");
8774
8775 return skip;
8776}
8777
8778bool StatelessValidation::manual_PreCallValidateGetDeviceImageSparseMemoryRequirementsKHR(
8779 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, uint32_t *pSparseMemoryRequirementCount,
8780 VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) const {
8781 bool skip = false;
8782
8783 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageSparseMemoryRequirementsKHR");
8784
8785 return skip;
8786}
Tony-LunarG115f89d2022-06-15 10:53:22 -06008787
8788#ifdef VK_USE_PLATFORM_METAL_EXT
8789bool StatelessValidation::manual_PreCallValidateExportMetalObjectsEXT(VkDevice device,
8790 VkExportMetalObjectsInfoEXT *pMetalObjectsInfo) const {
8791 bool skip = false;
8792 const VkStructureType allowed_structs_vk_export_metal_objects_info[] = {
8793 VK_STRUCTURE_TYPE_EXPORT_METAL_BUFFER_INFO_EXT, VK_STRUCTURE_TYPE_EXPORT_METAL_COMMAND_QUEUE_INFO_EXT,
8794 VK_STRUCTURE_TYPE_EXPORT_METAL_DEVICE_INFO_EXT, VK_STRUCTURE_TYPE_EXPORT_METAL_IO_SURFACE_INFO_EXT,
8795 VK_STRUCTURE_TYPE_EXPORT_METAL_SHARED_EVENT_INFO_EXT, VK_STRUCTURE_TYPE_EXPORT_METAL_TEXTURE_INFO_EXT,
8796 };
8797 skip |= validate_struct_pnext("vkExportMetalObjectsEXT", "pMetalObjectsInfo->pNext",
8798 "VkExportMetalBufferInfoEXT, VkExportMetalCommandQueueInfoEXT, VkExportMetalDeviceInfoEXT, "
8799 "VkExportMetalIOSurfaceInfoEXT, VkExportMetalSharedEventInfoEXT, VkExportMetalTextureInfoEXT",
8800 pMetalObjectsInfo->pNext, ARRAY_SIZE(allowed_structs_vk_export_metal_objects_info),
8801 allowed_structs_vk_export_metal_objects_info, GeneratedVulkanHeaderVersion,
8802 "VUID-VkExportMetalObjectsInfoEXT-pNext-pNext", "VUID-VkExportMetalObjectsInfoEXT-sType-unique",
8803 false, true);
8804 return skip;
8805}
8806#endif // VK_USE_PLATFORM_METAL_EXT